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)
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
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.
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
Useful Links:
Did this article help?. If it did please Mark as answer.
There are limits to datastores. Sometimes it needs to create a waiting list if it has to many requests, and so it will freeze the game. Try adding wait functions, removing or loosening your autosave function (if you have one), or try to save player's data when they leave, and remove those lines where you save data when the server closes.