Teleporting Players to Reserved Server Safely With Match Data

So the way I am currently approaching this is that I am saving match data to Data Store Service and then giving that data store key to each player when I send them to a reserved server. Then once the players teleport to the game I wait for all of the players to join and then I take every key I have received from the clients and compare them all. If there is one that doesn’t match up with the rest, I just ignore it and use the matching key to get the match’s data.

This method still seems unstable for me and kinda spooky. I’ve noticed a few times when all the players join, the match won’t start. I am still not totally sure if this is causing the issue but I am still curious to see how other people handle sending match info to a reserved server. Such as characters the players have chosen / team sides.

TL;DR: How do you approach sending match data safely to a reserved server through the clients?

1 Like

You should never pass server data through clients, of course at risk of the clients manipulating such data. Always keep it specific to the server.

Keep in mind that a string is returned from using ReserveServer. This serves as the InstanceId, or otherwise the unique identifier for the server that you will be using. If you wish to save match data, establish this as a key within a “MatchData” DataStore, with the value being a table of whatever data is required for the match.

When the instance that players get teleported to has a minimum of one player, the instance is considered instantiated. Have the server retrieve the data from the MatchData DataStore, passing the ServerId (some property in the DataModel, forget what) as the key. What gets returned should be the table of data that is specific to that Instance. From there, you can work based on that data. It would also be helpful to cache that somewhere so it’s accessible without having to call the DataStore again - I’d recommend _G.

1 Like

Recently there was a change to make sending secure teleport data possible.

7 Likes

In relation to this, the following change was also made to the ReserveServer method.

For your intentions I imagine it is more suitable.


Save your match data to a DataStore with the PrivateServerId as the key, then you’ll be able to read it using the reserved server’s PrivateServerId on DataModel.

Matchmaking Server

local accessCode, privateServerId = teleportService:ReserveServer(placeId)
dataStore:SetAsync(privateServerId, matchData)

Match Server

local matchData = dataStore:GetAsync(game.PrivateServerId)
10 Likes

Awesome!!!

oh wait thats what i posted earlier