I’m trying to add a rejoin function to my game so people who get disconnected can rejoin the match they were in. I have a function that adds in the reserve server’s key into their data when they join a match, so they have no problem rejoining the server if they disconnect.
The problem is that if the server does not exist anymore, it will just send them to a new instance of a reserved server. I can’t use MessageService to message to players to see if they’re still in game because the server doesnt exist anymore. Is there any way to detect if a reserved server still exists through the access code without creating a new instance and without MessageService?
You can detect if a reserved server still exists by checking if the key is still valid. You can use the game:GetService("ReplicatedStorage"):FindFirstChild(key) method to check if the key exists in the ReplicatedStorage of the game. If the key exists, it means the server still exists, otherwise, it means the server no longer exists.
Check this code:
local key = "reservedServerKey"
local success, result = pcall(function()
if success and result then
-- The reserved server still exists
-- The reserved server no longer exists
This code tries to find the reserved server key in the ReplicatedStorage using game:GetService("ReplicatedStorage"):FindFirstChild(key) . If it succeeds, it means the reserved server still exists, and you can safely rejoin the server. If it fails, it means the reserved server no longer exists, and you’ll need to join a different server.
I can assume that this response was written by ChatGPT since it is incorrect and is not interpreting “data” correctly.
Furthermore, if ReplicatedStorage’s key does not exist, we cannot know if the server still exists if all players disconnect, because BindToClose fires before all players leave the game.
That’s where MemoryStoreService comes in. I don’t know exactly what you are asking for, but I’m sure you can use this service and add a sorted map to temporarily store data about where the players should go if they disconnect.