Hi fellow Robloxians! I have tried to make this Data Persistence Script but it seems not to be working. I have tested it and the part that seems to not be working is that it won't add the point to quest. Can someone help me?
scoreKey = "PlayerScore"
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady()then
--create leaderstats
local ls = Instance.new("IntValue")
ls.Name = "leaderstats"
ls.Parent = player
--create the score stat
local quest = Instance.new("IntValue")
quest.Name = "Quest"
quest.Parent = ls
quest.Value = quest.Value +1
quest.Value = player:LoadNumber(scoreKey)
end
end)
game.Players.PlayerRemoving:connect(function(player)
if player:findFirstChild("leaderstats") then
player:SaveNumber(scoreKey, player.leaderstats.Quest.Value)
end
end)
