Shutdowns Servers Command

I’m going to make this shirt and sweet.

Is it possible to make some sort of chat command that shuts down every server in my game?

I know it’s possible to shutdown one server, but can you do it with all servers?

If so, can someone give me an idea of how?

1 Like

Messaging service for i loops and player:Kick() is all you need. I cant type well as I am on mobile and I am not a mobile guys.

1 Like

this a great video with some good explanations.
were you looking for soft shutdowns?

1 Like

Not sure why you would need when you can close it directly here.

image

Soft shutdown is completely different then what the user is looking for in this post. The user is trying to make everyone get kicked on when a command is run inside of a server.

A soft shutdown on the other hand just puts all players in a temp server and then will re-join the user to a server when the servers start up again. Soft shutdowns are often used so people don’t leave servers so you can keep your player count and so people don’t lose contact to people they are playing with.

1 Like

According to several reliable sources, that button is unreliable.

I’m trying to make a command that shuts down every server in the game. I don’t know if its possible, but if it is, I’d like some ideas :slight_smile:

Not sure, have worked fine for me (I have only used them on smallish experiences with 3-4 servers max). If it is not reliable to shut down servers then that is somthing I would suggest you contact the dev relations team about.

You could use what @Qinrir said.

Bug reports have already been filed for the issue.

I don’t really understand what he meant. I don’t have any knowledge with MessagingService.

Message server allow you to run stuff sent from a different server. I highly recommend checking the docs if you have never used MessagingService.

Yes, It’s pretty easy!

Firstly you want to get a .Chatted Event

game:GetService("Players").PlayerAdded:Connect(function(player)
   player.Chatted:Connect(function(msg)
   end)
end)

Now lets add a check to make sure its the game owner & that its the correct command

game:GetService("Players").PlayerAdded:Connect(function(player)
   player.Chatted:Connect(function(msg)
       if msg:lower() == "!shutdown" and player.UserId == game.CreatorId then

       end
   end)
end)

Now lets add a MessagingService Subscribe Function

local MessagingService = game:GetService("MessagingService")
game:GetService("Players").PlayerAdded:Connect(function(player)
   player.Chatted:Connect(function(msg)
       if msg:lower() == "!shutdown" and player.UserId == game.CreatorId then  
          MessagingService:PublishAsync("ShutdownServers", "Some message not really needed")
       end
   end)
end)

Now lets add the shutdown core! this will shutdown all servers.

local MessagingService = game:GetService("MessagingService")
game:GetService("Players").PlayerAdded:Connect(function(player)
   player.Chatted:Connect(function(msg)
       if msg:lower() == "!shutdown" and player.UserId == game.CreatorId then  
          MessagingService:PublishAsync("ShutdownServers", "Some message not really needed")
       end
   end)
end)

MessagingService:SubscribeAsync("ShutdownServers", function(message)
   for i,v in pairs(game:GetService("Players"):GetPlayers()) do
     v:Kick("Server Shutdown")
   end
end)

and… Done!

Wow! I had no clue you could do that with MessangingService. Seems like I have alot to learn.

Thanks a lot!

Does your script shutdown every server in the game?

1 Like

Yes! It shutdowns every server in the game.

3 Likes