I’m trying to create an event server with a bigger server size that people can join from normal servers.
The way I’m doing it is that I have the main place and the event place. A host can send “/e startEventServer” in the chat of the main place, and then it uses TeleportService:ReserveServer() to create the event server, which it then teleports the host to.
Once an event server is open, every minute it sends out a message to all the main servers with MessagingService:PublishAsync() along with the game.PrivateServerId. When a main server recieves that message it sets up a teleporter and stores the PrivateServerId. When someone then interacts with the teleporter, it uses TeleportService:TeleportToPrivateServer() to teleport the player to the event server, using the stored PrivateServerId as the code.
However when I try to teleport to the server it gives me the error code 773 tellling me the place is restricted.
I think I figured out the issue, though I have no idea why it happens though. When I reserve the server, I print the code into the console, and when I recieve the message, I print that code into the console, and for some reason those two codes are different.
I have no idea why this is happening and I’ve been looking around for answers for hours without any luck.
If anyone could help me with this issue, or maybe suggest a better way I could do this, that would be really helpful.
I just checked the PrivateServerId in the event server and it doesn’t seem that messagingservice is sending the wrong data, rather that using the code ReserverServer() gave me sends me to a server with a completely different code? That makes even less sense and now I’m completely lost again as to why it shouldn’t let me teleport. The event servers code matches the code it sends to the other servers, so it should still let you teleport there?
I also had a similar issue to you, where PrivateServerId and ReservedServerAccessCode are different. That is why I replied to that post so that other people don’t face the same issue, and I’m glad it helped you! Tbh, I found out by experimenting with it, where I found they are actually 2 different things.
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 “:ReserverServer” method. My guess is that Roblox did this for security reasons (which is fair).
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. MemoryStore is basically RAM that can be accessed by all servers and places within your experience. You can set the data to be saved up to 45 days or less, which is the perfect use case for this.