Reserve Server Access Code

The issue I’m talking about seems to be known a little about in this community. However, I’m trying to make it so when the player joins the lobby they will be put into any current active reserve servers. I understand that I need to save the IDs of the reserved servers in the data store and then have a getAsync() in the main lobby. I’m having a hard time retrieving the reserve server ID. The way I look at it, in order to get the “Access Code” I do this:

print(TS:ReserveServer(game.PlaceId))

In the reserved server the output shows something like this:
_c8vHbUkjdsoF5pnu5mSY7MQruUdTFRNClQostuQaayQBJVgVAQAAAA2

So my friends and I did some testing and one person would join the reserved server to get the code and stay in it. The other friend would paste the ID and click Join. It would then join a different server. But the first friend who also pastes the ID and clicks join, they join the same server…

Better example

Person 1: Joins reserved server 1 to retrieve ID

Person 2: Joins via the ID and makes a Reserved server 2 (Not joining the reserved server 1)

Person 1: Joins via the Id and joins Reserved server 2…

So I guess what I’m trying to say is, how do I get the reserved server ID to put in the datastore, so that other players in the lobby can join that specific reserve server?

Very familiar with this: Can i get acces code from reserved server?

TeleportService:ReserveServer() actually returns a tuple (multiple values). The first of which is the access code which you have been using. The second returned value however should be the private server id.

local access_code, private_server_id = TS:ReserveServer(game.PlaceId))
print('Access Code: "' .. tostring(access_code) .. '"')
print('Private Server ID: "' .. tostring(private_server_id ) .. '"')

So when your main server reserves another server, it should save this access code and private server id in the datastore for later use.

5 Likes

Right, so I save the access code as the value and the preivateServerId as the key. But when the player in the lobby tries to join the active reserved server, it just puts them in a different one. (Using that saved access code)

Huh. Seems like a bug to me. Roblox’s teleport service shouldn’t be doing that, have you tried skipping the data store and directly sending both players to the reserver server one after the other immediately after reserving the server? It sounds like one player might be teleported using an old access code, perhaps the previous code stored in the datastore.

Okay, sorry about that. It does save and I use RemoveAsync() When the reserved server shutdowns. However, I want the main lobby to know how many players are in the reserved server to it doesn’t tp a person to a full server. How would I go about telling the lobby how many players there in the reserved server, providing it knows which reserved server specifically using MessageService?