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

Does roblox have a shutdown function?

I'm wondering if roblox has a shutdown function? If not how could I do this? I've gotten this far, although I'm not sure what to do next:

players = game.Players:GetChildren()
for 1,#players,1 do
	-- I know I can use :Kick() somehow, although how could I possibly accomplish this? How do I grab the player?
end

1 answer

✓ Accepted answer

Currently there is not a function available to shut down a server via a script, you will need to kick all of the players on the server.

It would be best to use the function GetPlayers and loop kick the players.

Example:-

for _, plr in pairs(game.Players:GetPlayers()) do
	plr:Kick('Server shutdown')
end

-- your example
local plrList = game.Players:GetPlayers() -- passes back an array
for i=1, #plrList do
	plrList[i]:Kick('Server shutdown')  -- we access the array index and kick that player
end

You may also want to kick all players that join the game as well.

game.Players.PlayerAdded:Connect(function(plr)
	plr:Kick('Server shutdown')
end

I hope this helps.

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