Minecraft – Will this command block always teleport the correct player(s)

minecraft-commandsminecraft-java-edition

Does that teleport the player closest to the command block or the player closet to the coordinates in the execute portion?

May goal is to teleport anyone that steps in a specific block, but I want to make sure I'm doing it right

/execute @a[x=112,y=34,z=14,r=1] ~ ~ ~ tp @p 90 29 8

Best Answer

You should skip the execute command and use the target selector with arguments in the tp command:

/tp @a[x=112,y=34,z=14,r=1] 90 29 8

If you want to use the execute command for some reason, use the @s target selector in the tp portion of the command. This selects the entity which executed the command. This would be the same entity the execute command targeted within the coordinates:

/execute @a[x=112,y=34,z=14,r=1] ~ ~ ~ tp @s 90 29 8