I managed a KitPvP server in Minecraft and everything works fine except when players wants to duel each other. They get sent to a room where they will be dueling. The main problem is when the winner wins, I have no idea how to teleport them back to spawn.
Check for the other person not being there. You can do this by tagging an arbitrary player inside the room (would be the only one if he/she won), then checking if there's another untagged one and then removing the tag again:
/tag @p[x=…,y=…,z=…,dx=…,dy=…,dz=…] add inRoom /execute unless @p[x=…,y=…,z=…,dx=…,dy=…,dz=…,tag=!inRoom] as @p[tag=inRoom] run <command> /tag @a remove inRoom
…" with the lowest coordinates and the size of the room and "
<command>" with whatever you want to do with the winning player (for example teleportation). If you want to do it relative to that player's location, add "
at @s" before "