The title sounds really weird as that’s not how it normally works, but I’m making a private server system for a game, and I’m wondering how do I make it so when the player gets teleported to the reserved server, the reserved server knows who the owner of the “private server” is?
It’s not actually a private server, it’s a reserved server and the player gets teleported to it as a private server.
Pretty much when a player buys a gamepass, it gives them access to a reserved server and other people can join it if they have a code and I want it so the reserved server knows who owns it.
reserved servers do not have owners.
I know, but I’m using it as a private server system.
When a player buys a gamepass, it gives them access to a reserved server. Like how ER:LC or how bloxburg does. But in ER:LC or bloxburg, it also knows who the reserved server belongs to.
And you are creating a new ReservedServer each time the player wants to teleport there? Or you are storing the server key into a datastore when the player buys the gamepass?
If you are storing the key then you know who it belongs
I’m storing the server key into the datastore
What do you mean by this?
I mean, a player buys the gamepass and you run the ReserveServer functions to get the password of the server, then you are storing that password into player’s datastore right? Save the server id too. By checking the player’s datastore you have the id and password of the server the player owns
As hinted by @Dev_Peashie the easiest way of doing this would be passing the data over based on the purchase situation, as you already know who created the private server you can simply add too the data critical information such as the Owner UserID and the name (which can be useful as it means you don’t have to API search it).
As a reserved server will share the same datastores as the initial game - you can do a reverse lookup search to find it by accessing the datastore all over again. In order to pass information across the server-server boundary you can use the optional parameters given to the TeleportService to handle this behaviour.
An example of this is the SetTeleportSetting which allows you to send data across the boundary as necessary:
Creator Documentation - TeleportService:SetTeleportSetting()
For a fully server side approach, datastores are the way to go.
I’m doing a server side approach since I might be adding an admin to the reserve server soon, but I’m still confused on how I would make it so like there’s a way to check if the server the player is in matches with their key in their datastore?
Is it ok if you guys explain in more detail about how I can actually check I am still a bit confused.
With this you can check if the current server is a ReservedServer: game.PrivateServerId
Its the same ID that ReserveServer()
function gave you back when you created the Server for. ReserveServer()
will return the ServerID
and the AccessCode
to join that server. If you save both in DS, you can compare if the server the player is currently playing (game.PrivateServerId) is the same as the one you saved into player’s DS. If its equal, then that server belongs to that player
Thanks, I was wondering why people added a second variable when they do ReserveServer().
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.