Soft Shutdown Script

Ever wanted to restart all servers in your game without losing a bunch of players? I’ve written a script that does this. It works by hooking into game:BindToClose() and teleporting all players into a reserved server, which basically serves as a lobby. When a server spawns up, if it’s a reserved server (and not a VIP server), it will automatically wait a few seconds and then teleport players back into the main place.

Note that if you don’t wait before teleporting everyone back into the main game, the game will tend to match-make each player into their own server, which is why I added some wait() statements in between teleporting each player.

I’ve only tested this on small games (300 players, 10 servers) but I am curious how well it works on larger games. Please make pull requests if you figure out any improvements.

Script source:

458 Likes
Advanced Shutdown Script
Best method of shutting down a game
How do you shutdown without having players go back and press play?
Game Development Resources [MEGA THREAD]
Allow us to phase out old servers by preventing new players from joining
Creating Live Updates
Server shutdowns triggered by a proxy server using HTTPService - is this a bad idea?
[New softshutdown system]
Is there any other way to improve my DataStore more?
Force-reboot a server
Random server shutdown
Uniform server version number in configure place
What is the best way to update your games?
Is it possible to make a gui that pops up when I click the shutdown all servers button and it teleports everybody playing into a new server?
Soft Shutdown v2!?!
Updating Server Without Shutting It Down
Is it possible to make a manual global shutdown system?
Soft Shutdown Support
Introducing Migrate to Latest Update
Shutdown script not working!
Shutdown Message Warning On Update?
How do I restart the server and make all players reconnect?
How should I be using BindToClose()?
Is there any way to still show a gui when BindToClose?
Possible to present reconnect as an option for kicks?
Smooth Shutdowns - Update your game servers with ease
Do I kick people from servers when I update?
Soft Shutdown Not Working
Automatic/Artificial Shutdown Script
Teleport players on update
Shutting the server down problem
LoadAsset() Update?
Can't join games after shutdown
[Open Source] Custom queue
Introducing Migrate to Latest Update
Advice on making updates on a game
Auto update feature, don't know where to start

Thank you! I will have to try this out. If only we could link our script sources to github repositories…

16 Likes

This is great! I’ll definitely be using this in the future.

6 Likes

This is the most clever use of reserved servers I have seen. I will definitely try to implement a modified version for Ultimate Boxing (mainly the message).

13 Likes

Thank you so much for this! This’ll be pretty neat if any of my games actually get popular and I need to release an urgent update without losing all of my players!

8 Likes

This is a great use of reserved servers as now I won’t have to worry about loosing players! :grinning::grinning:

2 Likes

I made an identical system a few months back for my game but had to rip it out due to some issues.

The main issue was that no matter how long I waited it seemed some servers would never die fast enough so teleporting back would sometimes end up in old servers or fail attempting to join a dead server. I was doing everything like kicking any pkayers attempting to join etc. But no luck. It was a mess.

Since then teleportService and servers migt have become more reliable and it might be time for me to reimplement but im unsure,

EDIT: Read the code properly and realised it activated when the server was shutdown from the site anyways which is a smart alternative to what I was doing. I’m not sure if this would’ve solved my servers shutting down fast enough issue but it looks like it might have.

3 Likes

That’s the plus side of using reserved servers, no one will accidentally get placed into the ‘lobby’ servers.

Worth noting that there was also a bug that was only recently fixed where game.OnClose would kick out all players before you had the chance to teleport them out.

4 Likes

Cool, I might use this for my game.

Already implemented in my game and works like a charm. It’s almost fun for me to shut down servers now, just to watch the servers disappear and return within seconds!

3 Likes

Oh, no what I meant was:

I teleported all the players to reserved servers and let them wait there for a bit, then when I teleported them back sometimes some of the old serverrs would still be alive and they’d end up in those.

2 Likes

This may sound silly but is there a way to shutdown all servers via chat commands? Sometimes im testing a game and i say Shutdown to close a single one since my game isn’t very big.

1 Like

This is sweet! I will use it later on!

For anyone interested: Just shut down my servers with 1.4k CCU and everything turned out smoothly – only lost about 200 players. Datastores still working smoothly, no data lost. Love this script!

5 Likes

Now implemented and ready for the next Ultimate Boxing update. :grin:

22 Likes

Added to my game, with about 1k concurrent users, 90 servers. Will let you know how it goes.

14 Likes

That’s so simple, yet such a good solution for this. Innovation at its finest :slight_smile:

6 Likes

This sounds incredibly useful, I can’t wait to test it!

3 Likes

Has anyone run into this yet with this model?

I think he was talking about his old system of rebooting servers. Shouldn’t happen with soft shutdown.