This question already has an answer here:

I am not testing for a player.Ive already tried looking online for hours and tried several different versions of the teleport command. i looked up target by volume under commands but it seems i cant use it to teleport a specific player, only @a and @e, and so on...

im specifically looking for a command that will teleport a player away to different coordinates once they step within a certain range of other coordinates.

marked as duplicate by Fabian Röling, galacticninja, Robotnik Aug 17 at 14:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You can execute a command as a certain player by using /execute as:

/execute as <player>

You can then use if and a target selector to define your area, or other things that you may want to define:

/execute as <player> if entity @s[<definition for the area>]

Now you only need to run your /tp command:

/execute as <player> if entity @s[<definition for the area>] run tp <target coordinates>

You can also just add the name to the target selector for an easier solution:

/tp @a[name=<name of the player>,<definition for the area>] <target coordinates>

This also works with @p if you specifically try to avoid @a and @e.

Here an example:

You want to teleport me (bearb001) to the coordinates 100 100 100 when I enter a spherical area with a radius of 5 blocks with the repeating command block in the center:

/tp @a[name=bearb001,distance=..5] 100 100 100
  • I didn't see your edit before posting this, if this answer doesn't help, then I recommend you check out this answer on this question. – bearb001 Aug 17 at 0:40
  • i have tried these but im having trouble. and the other answer you tagged after seeing my edit is what im doing right now, which also didnt work . im not trying to execute as a certain player, rather trying to tp a specific player only – sour Aug 17 at 1:19
  • You need to clarify that a bit, your description sounds like a combination of those two answers would be exactly what you are looking for, this explains how you teleport a specific player only, and the other answer explains how you get the definition for the area, maybe add some commands to your question, so people here can see what you've tried. And if you're not in the newest version, then add that, too. – bearb001 Aug 17 at 8:20
  • @sour I added an example now, I really hope that helps. – bearb001 Aug 17 at 21:41
  • thank you so much, im not the sharpest pencil, so i undertood with the example, thank you so much! – sour Aug 18 at 15:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.