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

Best way to shutdown a server? [closed]

Asked by
Merely 2122 Moderation Voter Community Moderator
10 years ago

This question has been solved by the original poster.

In the past I have used Instance.new("ManualSurfaceJointInstance") from a server script, but it still takes a little bit of time for the old server to die out. Is there a faster way? Last time I checked, RequestShutdown didn't work.

5
That method is indeed the best way that is available to us right now. User#11893 186 — 10y

Locked by Thewsomeguy and AmericanStripes

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

5 answers

Log in to vote
1
Answered by
Axstin 55
10 years ago

I think disconnecting all clients that are connected will shutdown the server. Correct me if I'm wrong.

Player::Kick disconnects a client from the server, causing the player to see a "The game has shut down" message.

for i, v in next, game:GetService"Players":GetPlayers() do
    v:Kick()
end

Hope this helps.

Ad
Log in to vote
0
Answered by 10 years ago

You could always just remove all the players in the server.

for _,v in pairs(game.Players:GetPlayers()) do
    v:Kick(); --This or
    v:Destroy();
    shutdown = true
end

game.Players.PlayerAdded:connect(function(plr)
    if shutdown then
        plr:Kick();
        plr:Destroy();
    end
end
1
Players can simply rejoin the server. I want to actually shut it down. Merely 2122 — 10y
0
Just have an auto-kick in the :PlayerAdded function. PiggyJingles 358 — 10y
Log in to vote
0
Answered by 10 years ago

Create a script for Shutdown, in that script give every player's character a LocalScript with this in it: I don't think there's a better solution than this to shutdown a server at the minute.

Instance.new("ManualSurfaceJointInstance", Character) -- Remember to define Character.
2
No. That has the same effect as kicking the player. Crashing the player is never a good idea. User#11893 186 — 10y
Log in to vote
0
Answered by 10 years ago

I have a simpler script.

for k,v in pairs(game.Players:GetPlayers()) do 
v:Kick()
end
Log in to vote
-2
Answered by
TheMyrco 375 Moderation Voter
10 years ago

Good point. This has been a point of discussing for many years: what is the most effective way to shutdown a server? Crashing? Requesting? Kicking?

The most common methods areInstance.new("ManualSurfaceJointInstance", workspace) and workspace:ClearAllChildren() + crash (while true do end), or simply just crashing.

The best, in my opinion, is the second option: clearing everything and then crashing.

But, I wonder why you want to know this. It achieves the same result, doesn't it? Perhaps a little slower, but still, death will overflow.

2
Actually, Workspace:ClearAllChildren() errors due to Terrain not being able to be removed. TheGuyWithAShortName 673 — 10y