function onPlayerEntered(player)
local d = 0
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("Stats")
if player.DataReady then
if player:findFirstChild("Stats") then
repeat wait() until player.Stats:findFirstChild("MoneyBalance")
local score = player.Stats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
print("StatSaved")
end
end
d = 1
else
wait(0.1)
return
end
end
while d==1 do
wait(10)
save(player)
end
end
function save(plr)
local score = plr.Stats:GetChildren()
score.Parent = game.ServerStorage
for i = 1,#score do
plr:SaveNumber(score[i].Name)
end
print("StatSaved")
end
game.Players.PlayerAdded:connect(onPlayerEntered)
---I want to save this instantly btw, and I don't know how to. |