Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a server shut down if every player has died?

Asked by 1 year ago

Hello. I have recently been working on a zombie survival game.

It's like one of those games where you enter a "lift" with 1 or more players and then get into another server, where the game actually goes underway.

Since I'm making a zombie survival game, if every person in the server dies, I want the server to shutdown, so they have to go back to the lobby to begin another game.

Any help is greatly appreciated!

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

If you are using the Teams service to separate the alive players from the dead players, you can use the method GetPlayers to get a table of all the players on the 'alive' team.

If you are not using the Teams service, you could create a table to track the players that are alive and, whenever a player dies, remove them from that table.

When the table reaches a point where there are no contents inside (indicating that all the players are no longer alive), you can either use the Kick method on each player or teleport them back to the lobby by using TeleportService.

Ad

Answer this question