I have a script that saves a player's leaderstats for how many kills that player has achieved. Here's the script:
game.Players.PlayerRemoving:connect(function(player) local s = player:findFirstChild("leaderstats") if s then local k = s:findFirstChild("Kills") player:SaveNumber("kill", k.Value) end end) game.Players.PlayerAdded:connect(function(player) if player:WaitForDataReady() then player:LoadNumber("kill") end end)
The problem is that the script doesn't do anything. I tried putting print("check") in both lines of code and nothing showed up in the output. Any help?
LoadNumber returns a number.
You aren't doing anything with that number. Line 11 is just like setting
math.sqrt(15)
on its own.
Set the value of kills
:
player:WaitForChild("leaderstats"):WaitForChild("Kills").Value = player:LoadNumber("kill")