game.Players.PlayerRemoving:Connect(function(player) -- when player leaves
    local ID = currencyName.."_"..player.UserId
    DataStore:SetAsync(ID,{player.leaderstats[currencyName].Value,
        player.leaderstats[currencyName2].Value,
    player.leaderstats[currencyName3].Value})
end)

game:BindToClose(function() -- when game is shutting down
    for i, player in pairs(game.Players:GetPlayers()) do
        if player then
            local ID = currencyName.."_"..player.UserId
            DataStore:SetAsync(ID,{player.leaderstats[currencyName].Value,
            player.leaderstats[currencyName2].Value,
            player.leaderstats[currencyName3].Value})
        end
    end
end)

Error caused: Not running script because past shutdown deadline

Can't seem to figure out what is causing it as it shouldn't take 30seconds to save to the datastore, which is the only thing both of these do.. Anyone got any clues to what I am doing wrong?

Thanks in advance.

4 comments

0

I got that too, I think it is because of the Bind to close. idk how to fix it though

0

It is.The game needs to shut down eventually.

0

It takes a long time to shutdown though now :/

0

Same here. It gives me this error but it saves.