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

Does roblox have a shutdown function?

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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.

Ad

Answer this question