Make it so datastore doesnt exhaust with autosave?

Hello devfourm,

I have an autosave system which works fine as it is, however, if lets say a player leaves before the cooldown for the interval between each save is reaches then it exhausts (saves during autosave and then tries to save when they leave). Is there a way to combat this? The system itself works fine, I just want to know if there’s a way to make that ‘impossible’, because I really don’t want any chance for my system to possibly fail if that happened to a player.

1 Like

As long as you save data once every > 60 seconds for every player, you will have a backup save for when they leave.

The equation for the amount of times you can save per minute is
60 + numPlayers × 10

So, if you save <=5 keys for each player every minute, you will have enough. (This assumes you use the 60 for other server things). Its really hard to go over the limit unless you save inefficiently.

1 Like

Yeah, I do something like that, my method is rather 60 / numPlayers, however, for each player. Is that alright?


I’d use the 1 save every minute rule. It works perfectly in almost every case.

1 Like

Just record a list of players and their tick() when they were autosaved. When they leave, compare the current tick() to the player in the list’s tick() with your given amount of seconds that it has to surpass.

local list = {}

while true do
    for _, player in pairs(players:GetChildren()) do
        list[player] = tick()
        -- auto save

    if list[player] and tick() - list[player] >= 5 then -- example

1 Like