M BUZZ CRAZE NEWS
// updates

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

By Mia Morrison

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.

3

4 Answers

1.9 Solution

Place the following command in a repeating command block set to always active:

/execute @a[x=a,y=b,z=c,r=d] ~ ~ ~ tp @p e f g

Where:

  • a, b, and c are the XYZ co-ordinates that you want to teleport players from
  • d is the radius in blocks around that point where players will be selected (min 1)
  • e, f, and g are the XYZ co-ordinates that you want to teleport players to (i.e. the destination)

1.8 Solution

Use the same command as above, but since no repeating command blocks exist, place the command block on a fill clock.

3

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.

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.

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.

1