0

# [UNSOLVED] How do I stop game from freezing when I end game to save data?

Edited 15 days ago

I have a script that saves data of a player before the player leaves the game. Sadly, this is causing the player to lag/freeze. (I have tested when disabling/commenting this script the game runs smoothly when exiting)

I also receive this warning message:

DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 96373787

The script:

game.OnClose = function()
for i, v in pairs(playerdata) do
datastore:SetAsync(i, v)
end
end


I have also tried (same problems/warnings/freezing):

game.Players.PlayerRemoving:Connect(function(player)
for i, v in pairs(playerdata) do
datastore:SetAsync(i, v)
end
end)


0

the warnings aren't important, just general info about datastore. However, I think you may want to try adding a wait(0.01) to the loop, like this:

game.OnClose = function()
for i, v in pairs(playerdata) do
datastore:SetAsync(i, v)
wait(0.01)
end
end

0
I didn't put it in the post, but I had already tried that, the problem still persists. hattim00 75 — 15d
0

Hello.

There are limits applied to the data store model. If an experience exceeds these limits, the service will automatically throttle the experience’s data store usage, causing requests to be placed in a queue.

## Cool Downs

Request Per Minute

Get

GetAsync() -- 60 + numPlayers × 10

Set

SetAsync() -- 60 + numPlayers × 10

IncrementAsync() -- 60 + numPlayers × 10

UpdateAsync() -- 60 + numPlayers × 10

RemoveAsync() -- 60 + numPlayers × 10

Get Sorted

GetSortedAsync() -- 5 + numPlayers × 2

Get Version

GetVersionAsync() -- 5 + numPlayers × 2

List

ListDataStoresAsync() -- 5 + numPlayers × 2

ListKeysAsync() -- 5 + numPlayers × 2

ListVersionsAsync() -- 5 + numPlayers × 2

Remove

RemoveVersionAsync() -- 5 + numPlayers × 2

Rewriting Data Or saving Data has a 6 seconds Cools down

Data Stores

0
This did not help in the slightest. All you did is explain what I said already it in different words (it freezes/throttles when exiting the game) The question is how do I stop that, not what it is because I already know what it is hattim00 75 — 15d