At the part where you unload the data, you loop through expecting the data to be in the same order as the leaderstats - this is probably the issue, it’s loading data for the wrong leaderstat.
I recommend when you save the data, to include the index as the name:
local save = {}
for _, v in pairs(player.leaderstats:GetChildren()) do
save[v.Name] = v.Value
end
Then when you unload it, you can use the index:
for _, v in pairs(script.leaderstats:GetChildren()) do
local stat = Instance.new(v.ClassName)
stat.Name = v.Name
if savedValues[v.Name] ~= nil then
stat.Value = savedValues[v.Name]
end
stat.Parent = player.leaderstats
end
FYI: Using the 2nd argument of Instance.new is much slower than parenting it yourself, you can read more here: