How can I work out how many players are alive?

I have a 2D networked game. When all the players are dead I need them to respawn and start the game again. My question is how can I get a value with how many players are currently alive. My script uses Prefabs and spawns them in for all the players. All help is appreciated.

Try this:
First off if you dont have a server managing the communication between your game clients, you should define one of your players’s clients as a Master Client, the one that makes the decisions for all the other clients that you want to control, such as respawn.

Either on the server or master client keep a reference of each player connected to your networked play session, and ad a bool to that reference “_isDead”, or something like that, false at start. When a player dies update that bool to true, and parse each other player’s reference to check their _isDead bool too for true aswell.

If all the player’s references have their _isDead bool true send a request from your server/master client to the other clients to respawn and reset their _isDead bool back to false.