Using execute command to teleport a player under a certain height
I would try a completely different way of detecting players below y=27:
/execute @a ~ ~ ~ execute @s[y=0,dx=0,dy=27,dz=0] tp @s @e[tag=teleportTarget,count=1]
This first selects every player, then narrows down that list by only selecting those between y=0 and y=27 (you need no x and z range, but it might be required, so I specified it, too), then teleports them to the nearest entity with the "teleportTarget
" tag.
You can restrict that, for example if your map goes into the negative x direction, add ,dx=99999
to only select checkpoints within positive x direction.
Alternatively, you could use your idea of putting command blocks in different places, to be specific, the lowest x, y and z coordinates of the area where you want to teleport people to a certain checkpoint. Then you can simplify that command to:
/tp @a[dx=<range>,dy=27,dz=<range>] <coordinates of checkpoint>