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.
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).
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!
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.
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.
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!
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.
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.
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!