Here is the full script.

game.Players.PlayerRemoving:Connect(function(p)
if p:findFirstChild("leaderstats") then
p:SaveInstance("SavedStatPNum"..tostring(game.PlaceId),p.leaderstats)
end
end)
game.Players.PlayerAdded:Connect(function(p)
for k = 1, 60, 0.03 do
wait()
if p:findFirstChild("leaderstats") and p.DataReady then break end
end
local Loaded = nil
if p:findFirstChild("leaderstats") and pcall(function() Loaded =  p:LoadInstance("SavedStatPNum"..tostring(game.PlaceId)) end) then
**for j, v in pairs(Loaded:GetChildren()) do**
pcall(function() p.leaderstats[v.Name].Value = v.Value end)
end
end
end)

Line with two stars is the bug.

1 comment

0

Maybe change Loaded:GetChildren() to just Loaded. (You can't get children from a table or if it's still a nil value after)