The summary, the player died, they go into spectator, when the function is called they respawn where they originally died.
function WaveTransition(d: text):
if {_d} is "day":
set time in world "world" to 10:09 PM
broadcast "%time in world "world"%"
set {Transition} to true
set {-t} to 150
wait 2.5 seconds
set the gamerule doDaylightCycle of world "world" to true
broadcast "%time in world "world"%"
set {-t} to 5
broadcast "finish"
loop indices of {deathloc::*}:
set {_p} to loop-value parsed as player
broadcast "sdchi"
set {_l} to {deathloc::%loop-value%}
broadcast "sdi"
teleport {_p} to {_l}
broadcast "tele"
set {deathplList::*}'s gamemode to survival
broadcast "survive"
clear {deathplList::*}
clear {deathloc::*}
on death of a player:
if {gameactive} is true:
set {deathplayercount} to size of all players
if {deathplayercount} > 1:
set {deathloc::*} to victim's death location
set victim's gamemode to spectator
add victim to {deathplList::*}