Hello! this Data persistence script was working but now doesn't work anymore! what I should to do?
function onPlayerEntered(player)
wait() player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end
function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)

7 comments
please indent your code
Use DataStore. DataPersistence is deprecated. Also, I've seen that free model before. You should at least attempt to make what you want before you come to this site for help.
There's a question mark at the end of line 28
must be a really old fm you got out of toolbox
WaitForDataReady is deprecated, you should be using datastores. https://developer.roblox.com/articles/Saving-Player-Data
Not only is this a free model, but your other question was deleted for this same reason. Please attempt a save script, then repost it here if you encounter errors!
thanks guys I opened the URL which one auto svae leaderstats because my english language not good