Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make players leave a server then destroy the server?

Hi can someone teach me how to make all players leave a game? and also I have a question when all players leave a certain server does the server get destroyed?

Thanks

1 comment

0

Attempt ?

2 answers

✓ Accepted answer
When all players leave a game, the server is shutdown. To shutdown a server, you would have to remove all current players from the server like so:
for _,v in pairs(game:GetService("Players"):GetPlayers()) do
	v:Kick("Optional kick message here")
end

A server is shutdown when all players have left it. The easiest way is to destroy all of the Players in the players service

for _,v in pairs(game.Players:GetPlayers()) do
      v:Destroy()
end

1 comment

0

did you really just downvote my answer just to get yours accepted

This discussion is preserved as it was. New answers, comments, and votes are closed.