Okay, so, do your structure, put (for this example) a structure void (/give @s structure_void) at layer 5 (for example) under all blocks where TP is done.
Get a command-block, place it with "Repeat" mod and "Always Active" too, and put this command on:
execute as @a if block ~ 5 ~ structure_void run tp @s X Y Z
This command teleports all players who have a structure void at the layer 5 under their position at coordinates X Y Z.
'~X' means position at this coordinate, relative at the position of the player, with an offset of X. '~' is the same but with an offset of 0.
'~ 5 ~' means "at the same X and Z that the player, but at the layer 5 (fix, not relative)"