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

Best way to shutdown a server?

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.

1 comment

5

That method is indeed the best way that is available to us right now.

5 answers

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.

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

2 comments

1

Players can simply rejoin the server. I want to actually shut it down.

0

Just have an auto-kick in the :PlayerAdded function.

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.

1 comment

2

No. That has the same effect as kicking the player. Crashing the player is never a good idea.

I have a simpler script.

for k,v in pairs(game.Players:GetPlayers()) do 
v:Kick()
end

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.

1 comment

2

Actually, Workspace:ClearAllChildren() errors due to Terrain not being able to be removed.

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