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)
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.
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
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
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.
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
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)