0

I am trying to teleport all players who go to the Y level 8, but this command teleports all players from Y level 8 and the command block coordinates:

/execute if entity @a[y=8,distance=..10] run tp @s ~ ~100 ~

How do I make it so if someone goes to Y level 8 they teleport to safety? I already know how to teleport players at specific coordinates, but I don't know how to do this.

2

1 Answer 1

1

Note: this answer is simply for teleporting the player up 100 blocks after they reach y=8. It does not necessarily teleport the player to safety.

/execute as @a at @s if entity @s[y=8,distance=..10] run tp @s ~ ~100 ~.

You're close, but you need to use the at keyword to get the player's position rather than the command block's, and the as keyword to change the executor to the player.

The if then needs to be modified to use @s so it selects the correct person.

See documentation on the 'as' and 'at' keywords on the Minecraft wiki.

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