Is "DataStore request was added to queue" on ROBLOX STUDIO normal when saving on player exit and on server shut down?

I’m making a game and the stats get saved when the player leaves or the server shuts down, occasionally I get the following error when exiting playtest on the studio: DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key I’m assuming that its because when exiting playtest in ROBLOX studio its disconnecting the player and shutting the server at the same time so saving my players data 2 times. is this correct or should I investigate what’s causing the error ?

i used to get that error too on my simulator game and i assume it’s because we save data both when the player leaves and the server shuts down, so it’s not that big of a deal

Yes, this is correct. The server both shuts down and removes your player. You can add a simple RunService:IsStudio() in the PlayerRemoving to stop saving on player leave in Studio only.

The better way is to use a table to tell what players have had saved or not, when player data is loaded,

local ActivePlayers: {
    [Player]: boolean -- Players are the key, and the value is just gonna be true.
} = {}
-- ^ This can also be sometimes just the table where your player's data is stored, and it can be used for this as well.


--// On player loaded data:

-- Data loaded
ActivePlayers[Player] = true

--// On player left:
if ActivePlayers[Player] == nil then
    return
end

ActivePlayers[Player] = nil

-- Save data

--// BindToClose
local playersSaving = 0
for player in pairs(ActivePlayers) do
    task.spawn(function()
        playersSaving += 1
        -- Save data
        playersSaving -= 1
    end)
end

ActivePlayers = {}

while playersSaving > 0 do
    task.wait()
end

Correct me if I’m wrong, but this won’t actually fix the problem. On player leave, the data is never saved. (Didn’t see that, whoops) In addition, when the server shuts down, it will be trying to save all the remaining players’ data simultaneously, which will definitely trigger Datastore queue warnings.

It’s supposed to, but it shouldn’t be an issue. Only write requests to the same key give constant warnings, you will usually have a lot of DataStore budget otherwise.

His warning is a same key write warning, this doesn’t let anyone get saved twice, so that isn’t an issue.