Leaderstats join data not carrying?

I have this script where it detects when the player joins, and if it has teleport data, it should add it to their leaderstats. Although it is printing in the developer console, it doesn’t give the coins to thier balance. Any help?

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 * 10) / 10)," coins. It has been added to their balance.")
		plr:WaitForChild("leaderstats").Coins.Value += tpData.Coins
	end
end)

this is my teleport script.

local st = require(script.Parent.SafeTeleport)

game.ReplicatedStorage.Events.TeleportToPlace.OnServerEvent:Connect(function(plr, placeId, coinsToGive)
	local options = Instance.new("TeleportOptions")
	options:SetTeleportData({
		["Coins"] = coinsToGive
	})
	st(placeId, {plr}, options)
end)

UPDATE: It is adding the coins, just the leaderstats doesn’t show it visually for some reason.

2 Likes

Set the data in the match game.
Data is spread throughout the whole game and not just the place.

1 Like

Not sure what you mean, I did set the data in match.

1 Like

wasnt sure what “GetJoinData” was and so i searched it up and found this; i may be wrong but it looks like you’re setting a reward amount in the users TeleportData on the match server and then to be rewarded to their leaderstats once they teleport to the lobby server… but in the documentation it warns specifically about handling sensitive data (currency) using this method, as it is transmitted by the client themself?

i assume im unaware of something but in the case that you didnt notice this i just sent this reply as a warning :+1: