Data doesn't transfer with the player when teleporting to a new place

Yo guys, so I’m currently working on a big project and I want to teleport the player to a new place after clicking a button in the main menu, but I want the player to bring some data with him, but it does not work. The teleporting works fine btw.

Here is a local script in the place where there is the main menu :

local data = {}
data[“Race”] = player.Race.Value
data[“Spins”] = player.Spins.Value
data[“FirstTimePlayer”] = player.FirstTimePlayer.Value
data[“SpinsCounter”] = player.SpinsCounter.Value

main.EnterWorldButton.MouseButton1Click:Connect(function()
       game:GetService(“TeleportService”):Teleport(12031829590, player, data)
end)

And here is the local script in the new place, where the main game is :

local player = game.Players.LocalPlayer

local data = game:GetService("TeleportService"):GetLocalPlayerTeleportData()

if data then
    player.Race.Value = data["Race"]
    player.Spins.Value = data["Spins"]
    player.SpinsCounter.Value = data["SpinsCounter"]
    player.FirstTimePlayer.Value = data["FirstTimePlayer"]
else
    warn("NoData")
end

For some reasons data comes back nil.

Is the other place a sub place?

what do you mean by sub place?

Go into game settings on your main studio, then press places.


These are sub places, which share the same Datastore.

Like this :

Yes, exactly like that. Is the place you’re trying to get your datastore on one of those places?

yes it’s the one called The ChainsawVerse.

So if the DataStore has the same name in both places they will store the same data?

Yes, that is pretty much how a datastore works, it needs the same Datastore name to store the same Data.

Example, This is my main place.

And here is my sub place.

They need the same name.

2 Likes

Oh yeah, I just tested it and it works. Thank you man.

All good, have fun creating a game! And wish you best of luck!

1 Like

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