I have a game with datastores where i save how many coins a player has, what suits, and right now also how many eggs they have found. However I keep seeing this warning in my error report: ‘DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.’
I am not getting warnings about requests being dropped, only that they are being added to a queue. (I get notified for this because I have a pcall wrapped around every setasync and getasync.)
The problem is that I am not saving or loading data too often. Data gets saved or loaded in my game on either of these things:
-player joins the game
-player leaves the game
-game closes for some reason (bindtoclose and in a coroutine.wrap)
-when a player buys a devproduct
-autosaving once every 5 minutes.
I think that these are normal moments when data should be saved right?
In my game though, people can get teleported to many other places, when the data has to be loaded and saved again.
Could this be the issue, or is there something else as to why i am sending too many requests?
And if this is the issue, how do i fix this problem? Do I send player’s data with teleportdata when they get teleported or is this not secure? Any ideas would be appreciated!
Frequent player teleportation can overwhelm data store requests. A solution is to save data only when it changes, like when a player’s coins are updated, or a new item is added to a folder.
Im thinking of adding a new value named ‘ValueChanged’ and a function that listens to whether any data entry is changed, and then setting ValueChanged to true when it happens. And then only saving data when this ValueChanged is set to true. what do you think of that? could that be a good solution?
If you’ve got a BindToClose function, check if the current environment is studio. If it is, don’t save on the BindToClose, similar to what @SimoDevv said. Also, if you need to, increase your autosave interval. I’d recommend doing every 10 minutes.