How to get a reserved server access code from the reserved server?

Hello, I’m trying to make a script where someone can join a reserved server (The reserved server is a place by the way), the problem I’m having is that I can’t access the reserved server code. I’m also using cross messaging for this by the way

Does anyone have a solution for this? I’m really stuck here

2 Likes

When you use TeleportService and use TeleportService:ReserveServer it returns the code needed to be able to join reserved servers. If you’re on a ReservedServer server, you can use game.PrivateServerId to get the ReservedServer code (check if it’s not a string or <= 0.)

1 Like

This is partially incorrect.

game.PrivateServerId and ReservedServerAccessCode are not the same. If you try teleporting to a reserved server with game.PrivateServerId, you will get a restricted access error.

The only way to get ReservedServerAccessCode is through the return given by ReserveServer or TeleportAsync with “ShouldReserveServer” set to true in teleport options.

In other words, you can’t get a reserved server “ReserverServerAccessCode” from the same reserved server itself.


For my game, what I did was wherever “:ReserveServer” is used, I store the returned access code and private server ID (:ReserveServer does return 2 variables, not just 1). I then save the private server ID as a key, with the data being the ReservedServerAccessCode. This is because all reserved servers have access to the PrivateServerId, however, the ReservedServerAccessCode can only be obtained through the “:ReserveServer” method. My guess is that Roblox did this for security reasons (which is fair).

To get the access code from the reserved server, you just need to get the data via the key, which is game.PrivateServerId. This should then return the ReservedServerAccessCode.

As for how to save the key and data, you can either use DataStore, MessagingService or MemoryStore. Using MessagingService may be a bit odd to use to get this to work, so I would suggest using MemoryStore instead.


Be aware that Reserved Servers have a critical flaw when it comes to cross-compatibility with Xbox. More details here: Duplicate reserved servers created for XBox users with cross platform disabled

13 Likes

:happy4: thanks bro!! you saved me badly! :heart:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.