I'm working on a parkour map where if you fall off the map, it teleports you back to the start, so I need to teleport 1 player that is both Y=166 (for this example) and in a radius of 50 (for this example). The problem is when I execute the command it teleports all players that are in a 50 block radius, whether there in Y=166 or not, here's the command I'm working off of: execute @a[y=166,r=59] ~ ~ ~ tp @p -12.5 118 -27.5 and I have it set up in a repeat command block with always active.

2 Answers 2


Good question. I have spent a few hours playing with the mechanics of target selectors. I have reread the wiki a few times. I came up with a solution but it does not involve radius.

The problem is the initial target selector: @a[y=166,r=59]

This will select any player within a 59 block radius of y=166 directly above or below the command block. (If x and z are not specified it defaults to the command execution position) This radius means above and below y=166. When x and z of player are same coordinates as command block this would select anyone from y=107 to y=225.

If you use a volume argument to specify y, it only selects players inside the specified zone that also happens to be within the radius. Which without x and z seems to be only a few cubes directly above/below command block. Also doesn't work.

Also, I don't recommend using the execute command. Technically your command is finding a player based on the above criteria and then teleporting the nearest player(@p) to that position. Just use the tp command directly while targeting the player you want to with the target selector

One solution would be to specify a zone to target. This would use volume arguments instead of the radius argument. It requires a bit more.

/tp @a[x=X,dx=DX,y=166,dy=0,z=Z,dz=DZ] -12.5 118 -27.5

X and Z specify one corner of the zone tested.

DX and DZ specify the distance from X and Z respectively. (they are a distance, not a coordinate)

Note: Relative coordinates can not be used in the target selector.


/tp @a[x=-25,dx=50,y=166,dy=0,z=-25,dz=50] -12.5 118 -27.5

This will select and teleport any player between (-25,y,-25) and (25,y,25). This could sort of replace a radius of 50. It is not perfect, it seems to select any player above 164 and below 167.

In your case of a player falling off of a structure it will teleport them once they hit y=166.

Also, the command block has to be located in a loaded chunk. You could use a command block per zone of your map to have small targeted zones or you could put the command block in the spawn chunks and use one large zone that covers your entire map area.

Example of the latter:

/tp @a[x=-5000,dx=10000,y=166,dy=0,z=-5000,dz=10000] -12.5 118 -27.5

This would select and teleport any players between (-5000,y,-5000) and (5000,y,5000) at the correct y level.

  • 1. You get selected when any part of your hitbox is in the area. 2. You could use radius and box together by giving a tag to people in the radius and then test for box and tag together. Aug 25, 2017 at 19:56

This answer doesn't work. I keep it anyway, because it has valuable information in the comments.

You were actually right that x/y/z/dx/dy/dz and r/rm can be combined and that it only selects players who are in both regions. But you didn't specify a region for the y axis, so y=166 only moves the area you're searching in, it doesn't limit the area. To limit it, you have to enter any amount in dy, since you want the minimum, you currently have to use dy=1, in 1.13+ you'll be able to use dy=0.01

Also you don't have to use execute, so you can just do this:

tp @a[y=166,dy=1,r=59] -12.5 118 - 27.5

Also it's good that you used .5 in the coordinates, that way it works the same in 1.13.

  • I used that command and put it in a repeat command block set to always active, and now its not teleporting anything anymore, are you sure the right tag is 'dy'? Or am I doing something wrong? Aug 25, 2017 at 7:49
  • 1
    @Fabian I attempted this as well. I have a command block at (0,50,0) with tp @a[y=65,dy=1,r=5] ~ ~-10 ~. It will not detect me unless I am directly over the command block (0,65,0). If I remove dy argument, it will teleport me if I am within a 5 block radius of (0,65,0). Including dy seems to cancel radius, but without it, we are no longer testing for exact y position.
    – IronAnvil
    Aug 25, 2017 at 16:07
  • 1
    Apparently [y=65,dy=1] selects everything that has part of its hitbox at coordinates that round down to 65 or 66. That is very odd and I didn't know that. So you could just use [y=65] instead, like you originally did. But you need to give x and z coordinates/ranges, too. Since in theory you don't want to limit it at all, you can use @a[y=65,x=-30000000,dx=60000000,z=-30000000,dz=60000000]. But that moves your origin for the r= part. So I think there actually is no way to do it with one command. I'll rewrite my entire answer. Aug 25, 2017 at 19:37
  • 1
    @IronAnvil Yes, it uses x/y/z for the origin of dx/dy/dz and for the origin of r. That's pretty inconvenient, I don't know a case where you would actually want that. It basically selects the positive quadrant of the sphere (if dx/dy/dz is big). Aug 25, 2017 at 19:38
  • 1
    I posted a sort of work around answer. Not perfect. Thank you for your knowledge. I can not imagine a circumstance to use the positive quadrant of a radius. I can definitely say this question expanded my knowledge in regards to target selection.
    – IronAnvil
    Aug 25, 2017 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .