How to Teleport Players When They Enter a Certain Area/Coordinates

I am trying to teleport a player to certain coordinates once they enter an area.
The idea is that they walk into a really small building, but once they turn a corner, they get teleported into a larger building.
Please refer to the adventure map named '5 Cubed', if you need help understanding what I am asking.
Best Answer
1.13.x solution
If anyone is coming from 1.13.x, the /testfor command has been deleted. In that case if you want to teleport someone you can use the /execute command as thus
/execute if entity @a[x=0,y=0,z=0,distance=..1] run tp @p x y z
The first set of X Y Z coordinates is where you want the player to be teleported from, the second is where you want the player to be teleported to.
Pictures about "How to Teleport Players When They Enter a Certain Area/Coordinates"



Can you teleport someone to specific coordinates in Minecraft?
You can teleport other players, too. Just type their username before the coordinates \u2014 so if you're trying to teleport a player named JohnDoe, you'll type: /tp JohnDoe 70 70 70. And if all you want is to teleport yourself to JohnDoe (or any other player), just type: /tp JohnDoe.How do I trigger command blocks when a player walks in a certain area?
Try the /spreadplayers command, which spreads entities in a random area. The syntax is /spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player \u2026> In your case, you might want to try something like /spreadplayers ~ ~ 0 10000 false @a[r=5,c=1] .How to detect if a player is at a certain place! Java 1.16.1 COMMANDS IN DESCRIPTION
More answers regarding how to Teleport Players When They Enter a Certain Area/Coordinates
Answer 2
Put pressure plates around your desired area. under each pressure plate place a command block that will teleport you to coordinates of your choice. do this by inserting the command /tp @p x y z
into your command block.
Answer 3
It's actually quite easy:
Just have a command block that is on a clock, and it should constantly testfor a player at certain co-ords:
/testfor @a[x=???,y=???,z=???]
(copy exactly except replace ? with the co-ords) then put a comparater leading out of it to a command block that:
/tp @p ??? ??? ??? (x,y,z).
You can also do:
/test for @a[x=???,y=???,z=???,r=?]
Where r is a radius (i.e. if r is 3 it will test for players within 3 blocks in a directions of the co-ords specified.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Tony Schnagl, Robo Michalec, cottonbro, cottonbro