3

I can't seem to figure this out. I am trying to testfor if a player is near certain coordiantes, namely {-9, 100, 16}, and then to teleport them somewhere else.

In earlier versions it would be /testfor @a[x=-9,y=100,z=16,r=2] in a repeating command block going into a chain conditional command block that says /tp @p ~8 ~ ~, although it seems in 1.13 they have removed /testfor. I've seen that apparently I'm supposed to use /execute now in some way but I'm not sure how.

2

/execute already existed before and had most of the features it has now. But you don't even need that. Since you want to teleport relative to the command block, you can just use this:

/tp @a[x=-9,y=100,z=16,distance=..2] ~8 ~ ~

If you wanted to teleport the players 8 blocks from their location, you would use this:

execute as @a[x=-9,y=100,z=16,distance=..2] at @s run tp @s ~8 ~ ~
  • 2
    r also no longer exists, you'll need to use distance – SirBenet Jul 20 '18 at 7:30
  • That's right, corrected. – Fabian Röling Jul 20 '18 at 7:43
  • This does not work for me, any idea why? (Using Minecraft 1.13) – Enrique Bermúdez Feb 28 at 21:58
  • @Enrique You need to give way more details, in every way. – Fabian Röling Feb 28 at 23:02
  • I just added the next command to my command block: execute as @a[x=x,y=y,z=z,distance=..2] at @s run say Hello Now, sorry if i didn't explain myself at the first time, english is not my native language. With a 2 Observers clock, my command block is able to execute this command over and over again and shows the message as soon as the user gets in the coordinates indicated by me. Either way, if I stay still, it will be executed forever. I need to do two things: keep watching those coordinates permanently and execute the command just a single time, never again. Thanks in advance! – Enrique Bermúdez Mar 1 at 0:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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