Hey, so I’m working on DataStores and I was instructed that instead of kicking the player when data doesn’t load, I should have them rejoin the game. I assumed it’d just be with: TeleportService:Teleport(gameID, player)
But whenever I try that, it’ll rejoin the game, but after it rejoins, it brings up a prompt saying “Roblox has shutdown the server for maintenance. Please try again”
I forgot that Roblox does that, strangely, when you try to teleport a player to the PlaceId of the place you’re currently playing.
You can follow the soft shutdown paradigm by teleporting a player to a reserved server, wait some time (max 30 seconds) and then send the player back to a main server (teleporting back without the reserved server code).
So it’s sort of like a middleman place? So if data fails to load, I teleport to that place, then wait 10 seconds, then teleport them back to the actual place they tried to play?
While the cause for the message may be that Roblox closed the server due to a zero player count and all closed events finishing, doesn’t mean the code you proposed still works. This still needs to account for empty and full servers. OP already explained that teleporting them back in results in a server closure issue.
You also have no control over how fast a teleport happens, so, can’t do much there.
Assuming that everything that everyone has said up til now is true.
I’m about 100% sure you can get the current player count as well as the MaxPlayer count. So if you think you can’t account for empty and full servers at that point… Hmm.
Leaving a server with a zero player count will indeed shut it down. And you indeed don’t have any control over how fast a teleport happens. But if you were the last player in a server, simply teleport them to another server. Only time this won’t work is if you have the place set to a maximum of one player.
I’ve never used the services So this is just a use case based on the capabilities of the services.
But in the event that the server you’re currently in having more than x amount of players (or 1) you can take @colbert2677 's advice and teleport the player to a reserved server and then back to the main server.
Otherwise you can request another server VIA the MessagingService and get the JobID of a valid server that has more than x amount of players and teleport them there instead.
local TeleportService = game:GetService("TeleportService")
local Player = Player -- path to player
local reserveCode = TeleportService:ReserveServer(game.PlaceId)
TeleportService:TeleportToPrivateServer(game.PlaceId, reserveCode, { Player })