So i'm going by the Roblox Wiki page (which isn't very descriptive on everything) but in this line of code
scoreKey = "PlayerScore"
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
-- create leaderboard
local ls = Instance.new("IntValue")
ls.Name = "leaderstats"
ls.Parent = player
--create the score stat
local score = Instance.new("IntValue")
score.Name = "Score"
score.Parent = ls
score.Value = player:LoadNumber(scoreKey)
end
end)
game.Players.PlayerRemoving:connect(function(player)
if player:FindFirstChild("leaderstats") then
player:SaveNumber(scoreKey, player.leaderstats.Score.Value)
end
end)
theres a variable named scoreKey = "PlayerScore"
what does scoreKey do for data persistence if anything at all? and does it need to be changed based off of the leaderstat??
Because I see that the leaderstat is named "Score". Do I change "PlayerScore" to "PlayerGold?" for my leaderstat which is "Gold"

1 comment
oh okay thank you!