So I’m trying to use TeleportService and GetLocalPlayerTeleportData to send player play time as they teleport from place to place. I don’t want to use Datastores. Teleporting works but the data is not being transmitted. So here is my Teleport Script:
local player = game.Players:GetPlayerFromCharacter(char)
local pVars = player:WaitForChild("PlayerVars")
local pMessage = pVars:FindFirstChild("Message")
local pTimePlayed = pVars:FindFirstChild("TimePlayed")
local telePortData = {TimePlayed = pTimePlayed.Value, whatever = false}
pMessage.Value = "Teleporting in 10 secs"
teleportService:Teleport(PetTower, player)
teleportOptions:SetTeleportData(telePortData)
for i =1,3,1 do
wait(6)
end
teleportService:TeleportAsync(PetTower, {player},teleportOptions)
And here is the receiving end.
local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.TeleportRE
local Players = game:GetService("Players")
local player = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):wait()
local teleportData = TeleportService:GetLocalPlayerTeleportData()
local pVars = player:WaitForChild("PlayerVars")
local pMessage = pVars:FindFirstChild("Message")
pMessage.Value = "Time "
wait(1)
pMessage.Value = "Time2 "
wait(1)
if teleportData then
local timePlayed = teleportData.TimePlayed
pMessage.Value = "There's Data "
if timePlayed > 0 then
game.ReplicatedStorage.TimePlayedRE:FireServer(timePlayed)
end
end
if not teleportData then
pMessage.Value = "There's No Data "
end
After testing it, I’m getting the “There’s no data message” I checked the developer hub and pretty much copied and pasted what they did. All the messages are to check what is running and not running. And I have determined that the Data is either not being sent or not being received.
The Teleporter is in a server script and the Receiver is in a LocalScript.
I’ve checked the forums but their solutions didn’t solve my problem. any help is appreciated. Thanks