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

How do i shutdown a server?

Asked by
luachef 61
6 years ago
Edited 6 years ago

Does a good method even exist? Kicking all players still lets other players to join which won't shutdown it. I know that you can just kick every player that joins the server too but i don't like that way.

0
You would want to teleport the players not kick them. User#5423 17 — 6y

3 answers

Log in to vote
1
Answered by 6 years ago

All you have to do is go on your game page, and click the three dots on the top right corner. Then click "shut down all servers".

0
I'm making an admin script. I want to shut down in-game. luachef 61 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You could lock the server.

local serverLocked = false

game:GetService('Players').PlayerAdded:Connect(function(plr)
    if serverLocked == true then
        plr:Kick'Server is shut down!'
    end
end)

-- You can add your custom code to lock/unlock the server.
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You could use a trigger of some sort (ex: a RemoteEvent could be fired to a script to do this, or anything else you want) and iterate through the players in a for loop to repeatedly kick them until you cancel the "shut down." Example:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() --This is merely an example, do what you wish for the trigger function!
    for i, plr in pairs(game.Players:GetPlayers()) do
        plr:Kick("Server shutdown")
    end
end)

If you don't want to kick them, you could use :Destroy() if absolutely wanted, but it's not recommended so you could just teleport them to a server/place where they get kicked automatically on joining.

Answer this question