Minecraft – Teleport Player

minecraft-commandsminecraft-java-edition

I'm making a maze, and at certain parts the players need to be teleported.
This is my command so far:

/tp @a [x=-1034, y=34, z=-302 r=2] ~ ~ ~30

So this says, if a player is within 2 blocks of these coordinates then teleport the player 30 blocks south (positive z).

I can't have the command blocks at x=-1034, y=34 and z=-302, which is why that part of the command is necessary.

Can someone tell me if this command exists please!

Best Answer

The reason why it isn't working is because there is a space between the @a and the square brackets.

This command should work.

/tp @a[x=-1034,y=34,z=-302,r=2] ~ ~ ~30