Sending Data between places

So im creating a game where users can engage in boss battles but to reduce lag i’d want it in another game. So far I’ve created the place and the Boss and made it able to engage and fight the player. However Don’t know how to send leaderstats data between the hub and the boss battle and back again.

14 Likes

You could use DataStores. Their data can be accessed from any place within the universe.

2 Likes

DataStores is the best option, but TeleportService can send data while teleporting as well.

2 Likes

You could use datastores to make a random key for every user that joined the game and then just transfer the data by using the user’s key.

2 Likes

Would this video work?

4 Likes

Happy birthday! :cake:


To help you with the problem, using TeleportService is fine. You would first put all your leaderstats into a table, then use the Teleport() function to teleport the player:

local TPS = game:GetService("TeleportService")
local Stats = -- reference the leaderstats
local Table = {}

for i, v in pairs(Stats:GetChildren()) do
    table.insert(Table, v)
end)

TPS:Teleport(placeId, player to teleport, Table}

Then, inside a local script in a place that the player is teleported in, you can retrieve the data using GetLocalPlayerTeleportData():

local TPS = game:GetService("TeleportService")

local teleportData = TeleportService:GetLocalPlayerTeleportData()
9 Likes

Please DO NOT EVER use TeleportData for player data. This is also strongly discouraged in the Developer Hub as well. It is not fine at all. TeleportData is sent with the client and can be tampered. Although a server-side method of getting join data does exist, that doesn’t guarantee it’s not receiving false values and clients can use the Teleport method themselves (thus exploiters).

Any game critical data should NEVER be sent over using TeleportData. Use DataStores, they exist for a reason and are completely inaccessible to the client unless your code is structured horribly enough to allow clients to, through remotes, influence or directly control DataStores.

14 Likes

Thank you for telling me that, I’ve been trying to figure out how to do it but I’m having trouble. Is there a thread or examples that I can use to utilize this?

I’ve read this thread:

And it says to fetch the datastore the same way as you fetch the datastore in the start plcae

You won’t ever really need TeleportData, especially not when Shared Memory drops as per the 2020 High-Level Roadmap, assuming everything goes without a hitch and it does get pushed to production.

Right now, the only cases I’ve had for it are non-critical data that doesn’t need to be put in a DataStore and game security. For non-critical data, I’m referring to things like the details of the place they’re coming from to know if they entered through play or a teleport. For security purposes, see:

1 Like

Well you can just make a DataStore in your starting place and make sure every other places in the game’s universe has the same datastore, you can use embedding for this.

Although im not sure if embedding is a good idea, can someone correct me if im wrong?

I actually use MessagingService to send specific-match-tailored data from a lobby place server to an arena place server within the same game universe.

Soo far I have noticed no issues (other than a small inconsequential delay in sending / receiving). You can send ‘Variants’ which can be things like; arrays (tables), strings, numbers, etc, you name it. And the limits are very generous. At least for my purposes.

I wouldn’t use this for player data, just setting up a match based on the lobby info.

6 Likes

oh MessagingService is really great idea to send specific match tailored data, Thanks!!!