So I have a script, where if a player has teleport data, it will give the amount of coins to them. I am printing out the player’s leaderstats coin value before and after giving it, it does print the money out properly. BUT. The leaderstats coins value doesn’t even update, it stays at 0. I know this problem has NOTHING to do with my teleport data script, because simply ADDING the coins without the teleport doesn’t work. Here are some images.
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
for i, object in ipairs(char:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Player"
object.CanQuery = false
end
end
end)
local joinData = plr:GetJoinData()
local tpData = joinData.TeleportData
if tpData and tpData.Coins then
print(plr, "rejoined from a match and has earned", tpData.Coins," coins. It has been added to their balance.")
print(plr:WaitForChild("leaderstats").Coins.Value)
plr:WaitForChild("leaderstats").Coins.Value = plr:WaitForChild("leaderstats").Coins.Value + tpData.Coins
print(plr:WaitForChild("leaderstats").Coins.Value)
else
for i = 1,5 do
if tpData and tpData.Coins then
print(plr, "rejoined from a match and has earned", tpData.Coins," coins. It has been added to their balance.")
print(plr:WaitForChild("leaderstats").Coins.Value)
plr:WaitForChild("leaderstats").Coins.Value = plr:WaitForChild("leaderstats").Coins.Value + tpData.Coins
print(plr:WaitForChild("leaderstats").Coins.Value)
end
wait(0.1)
end
end
end)
i think it is becuase of your joinData() being nil,so since this is teleport service,you need the game ID as tpData.Watch the video about teleport service(related to coins value collection)
probably not because it errors out nothing and prints out everything perfectly when I simply do tpData.Coins. the problem is showing it on my default roblox leaderstats.
well, i didn’t gain much info from the video, but i did learn that for some reason, when I print everything inside of tpData, it prints, nil, and nil. I’m still pretty confused since it still says there’s 6 coins being added, even though it should be saying nil coins added, or even erroring the script.