Is There a Way to tp a player back to Spawn After Falling into Void?

I am making a mini-game for my server and would like the lobby to be a skyisland over the void, my question is, Is there a way to tp a player back to the skyisland if they fall in the void? I have a vanilla server and don't want to use plugins or mods if possible.(maybe a command?)


Solution 1:

For a world-wide area, can use /execute to change the coordinate origin to that of the player, and teleport them when they reach below y=0 (going downwards by 64 blocks):

/execute @a ~ ~ ~ /tp @a[c=1,y=-1,dy=-64] X Y Z

Or:

/execute @a ~ -1 ~ /tp @a[c=1,dy=-64] X Y Z

Solution 2:

/execute @a ~ -1 ~ /tp @a[c=1,dy=-64] X Y Z

@a: player

~ -1 ~: void coordinates

/tp @a[c=1,dy=-64]: teleports player

X Y Z: where to teleport player

Solution 3:

/execute at @a run tp @a[limit=1,y=-1,dy=-64] X Y Z for newer versions :]