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.
execute at @a if block ~ ~-1 ~ minecraft:grass_block run tp @p 273 20 -70 0 37