Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make this datastore save every 60 secounts?

Asked by 8 years ago
local key = "user-" .. player.userId

    local storeditems = datastore:GetAsync(key)
    if storeditems then
        Level.Value = storeditems[1]
        RealLevel.Value = storeditems[1]
        XP.Value = storeditems[2]
        RealXP.Value = storeditems[2]
        Tries.Value = storeditems[3]
        RealTries.Value = storeditems[3]
        Kills.Value = storeditems[4]
        RealKills.Value = storeditems[4]
    else
        local items = {Level.Value,RealLevel.Value, RealXP.Value, XP.Value, Tries.Value, RealTries.Value, Kills.Value, RealKills.Value} 
        datastore:SetAsync(key, items)

    end
end)

game.Players.PlayerRemoving:connect(function(player)
    local items = {player.leaderstats1.Level.Value, player.leaderstats1.XP.Value, player.leaderstats1.Tries.Value, player.leaderstats1.Kills.Value} 
    local key = "user-" .. player.userId
    datastore:SetAsync(key, items)
    wait(3)
    print(player.Name.."Left The Game")
0
Use a "while wait(60) do" loop TheHospitalDev 1134 — 8y

1 answer

Log in to vote
0
Answered by
Pejorem 164
8 years ago
while wait(60) true do
    for _, v in pairs(game.Players:GetPlayers()) do
        saveStats(v)
    end
end
Ad

Answer this question