How do i make this datastore save every 60 secounts?
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")