So I had someone help me make a working leaderboard script where whenver a player dies in any way He/She will get 10 Tokens "Money" and +1 to the Death value.. But for some reason I am getting this problem where it says "leaderstats is not a valid member of Player" and the leaderboard does not work correctly as once it will add values and then when I test the game again it will not add any values at all and they would just stay at 0.. And that just keeps changing each time I test it. I would really appreciate it if someone could help me fix this please!
This is the script that adds the values for each time a player dies.
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(plr)
local deaths = plr.leaderstats.Deaths
local tokens = plr.leaderstats.Tokens
plr.CharacterAdded:Connect(function(char)
char.Humanoid.Died:Connect(function()
deaths.Value = deaths.Value + 1
tokens.Value = tokens.Value + 10
end)
end)
end)

3 comments
Is there a separate script that adds the leaderstats when they join? There has to be one.
leaderstats is not a default roblox object, you gotta insert it first
Yes I have a script called "leaderboard" in ServerScriptService and in the leaderboard script I have the "Script" which I posted above, and I also have "leaderstats" in the leaderboard scripts with both values "Tokens" and "Deaths".