Simple question: How do I get the PrivateServerID out of :ReserveServer()?

My 2nd post here in one day! Wow.

Anyway, I’m working on a system that allows a lobby to find a server with a certain team available so people can join the team they want garunteed. Every server is a reserved server so that a game can find a specific server matching certain team criteria, if it is unable to find one, it’ll reserve a new one and save the AccessKey with the DataStore key being it’s PrivateServerId.

What I want this to do is to save the ServerAccessKey to the Datastore and use the PrivateServerId as it’s DataStore key. The lobby would get the PrivateServerId from a server via the MessagingService and look it up on the DataStore to get the associated AccessKey and join the server.

My only issue is, how on earth do I get the PrivateServerId from :ReserveServer()? It says it returns as a tuple on the wiki, but I can print what it returns and get what I assume is the AccessKey, but not the PrivateServerId? How would I get the PrivateServerId with ReserveServer()?

Hope this was easy enough to read, if code is needed then do inform me, I didn’t think it was neccesary in this scenario.



According to the documentation, it will come back as the second return value:

local accessCode, privateServerId = teleportService:ReserveServer(placeid)

If privateServerId is coming back as nil, then the documentation is wrong and needs to be fixed (or the ReserveServer method needs to be fixed).


Ahh fantastic, thank you. I didn’t actually know you could write variables like that before but of course, pcalls didn’t occur to me as they work the same way.

I knew that it was written as “tuple” on the wiki page but it showed no documentation how how this would be written. I should’ve figured that based on how pcalls work.

Thank you!

1 Like

Glad it works. I wish the documentation included a source example to grab the value.

1 Like