Minecraft 1.14.4 switch to Spectator Mode after death?

Re
3

I'm currently building a map with mini games in 1.14.4.
Now I wanted to go into Spectator Mode after you die and if only one player is alive everyone will be put back into Survival Mode, but all the commands I find are out of date…
Does anyone have any idea if that works?
Grüßle

Be

Are you doing the mini games with a data pack or with command blocks in the world?

Re

We used command blocks

Be

I gave you such a circuit in https://cdn.discordapp.com/attachments/655832016406708226/663786487346626561/Spectator_nach_dem_Tod.zip.