Data not tansfer to sub places

the title says it .the data didn’t teleport to other sub places.
This is the script:

—Server Side—

local DS = game:GetService("DataStoreService"):GetDataStore("ID")
local TS = game:GetService("TeleportService") 



game.ReplicatedStorage.RemoteEvent.TeleportEvent.TeleportPlayer.OnServerEvent:Connect(function(player)
	local data = DS:GetAsync('PlayerData') 
	if not data then data = {} end
	TS:Teleport(0000000000, player, data)
end)

—Client Side—

game.ReplicatedStorage.RemoteEvent.TeleportEvent.TeleportPlayer:FireServer(player)

any help is appreciated

Have you tried doing print(data) right after local data = …?

it print nil but why?? (((()))))

It prints nil because DS:GetAsync('PlayerData') is nil. You likely haven’t done DS:SetAsync('PlayerData', …) in your code properly, if at all. Consider setting it properly and using print statements to confirm it.

Do you mean this

local data = playerData:GetAsync(playerUserId)

this is script for my leaderstats

That line of code is not the same as local data = DS:GetAsync('PlayerData'). They’re referencing two completely different things.

do you mean I need to change it to this instead??

local data = playerData:GetAsync("PlayerData"..playerUserId)

sorry for bad grammar. I’m not good at English

You are trying to send a value from your Datastore to another place inside your game via client… First, that lets the client to change that data before arriving that new place…

If you already have the player’s info stored in a Datastore, would be better to get that data from inside the new place from the datastore, and not relying on the data that the client is carrying from the previous place.

One last thing, wheres the client script that reads the data on the 2nd place? you know the one using TeleportService:GetLocalPlayerTeleportData to read the data.
First try to send a simple string to see if you are able to read the data on the 2nd place

you mean I need to send string on 2nd place as data??

just to check if your client script using :GetLocalPlayerTeleportData is actually working.

But I insist.

You are reading Datastore on Place1, then trying to send that data on the client, then reading that client data on Place2

Would be better if you send nothing, and when the player joins Place2, you read the Datastore, and thats it. Not relying on client, they can change the value while teleporting

this is script from the 2nd place

–Serverside–

local DS = game:GetService("DataStoreService"):GetDataStore("PlayerData")
local newRemote = game.ReplicatedStorage.Remote.ArriveData.data

newRemote.OnServerEvent:Connect(function(plr, data)
	DS:SetAsync(plr.UserId, data)
end)

–Clientside–

local TS = game:GetService("TeleportService")

local newRemote = game.ReplicatedStorage.Remote.ArriveData.data
local data = TS:GetLocalPlayerTeleportData()

 game.Players.PlayerAdded:Connect(function()
    newRemote:FireServer(data)
	print(data)
	
end)

I did watch some tutorial about teleport service but idk if this code is the problems

You already have a Datastore in place, you can read that Datastore from any Place inside your game, you dont need to use a less secure way to transmit the data, just check the DataStore again inside Place2, and use it.

Hate to say this but…I dont quite get what ur trying to say…sorry

Sorry sometimes I explain things weirdly xD

Look, you have a datastore right? this one:

local DS = game:GetService("DataStoreService"):GetDataStore("ID")
local data = DS:GetAsync('PlayerData') 

When the player gets teleported to the Place2, just read that Datastore, and thats all.
Why you want to read the datastore on Place1, then send the data on client to the Place2? When you can only read the DataStore from Place2 when player joins

Owhhhh.so what you mean is I just get the data through like this

local DS = game:GetService("DataStoreService"):GetDataStore("ID")
local data = DS:GetAsync('PlayerData') 

right??

Emm yeah, partially. I mean thats only the references of your datastore, you should add a server script that on playerJoin use that datastore, gets the value and do whatever you want from that point.

Im just saying, if you already have that DataStore you dont need to send data on teleportation of the client

Somethings missing…there are’nt any data…I tried to print the data but nothing happens

game.Players.PlayerAdded:Connect(function(player)
    local DS = game:GetService("DataStoreService")
    local data = DS:GetAsync('PlayerData'..player.UserId) 
	print(data)
end)

Am I missing something??

Getting data from your datastore is not as easy. You should check some tutorials on getting data from datastore.

I almost got it working …but the data print nil.