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

Hey! I’m getting this error in the title.
Script:

players.PlayerRemoving:Connect(function(plr)
    --Save his data
    local success, errormessage = pcall(function()
        local realStats = plr:WaitForChild("realStats")
        local tableToSave = {realStats:WaitForChild("Coins").Value, realStats:WaitForChild("Gems").Value, realStats:WaitForChild("Gifts").Value}
        StatsDataStore:UpdateAsync(plr.UserId, function()
            return tableToSave
        end)
    end)
    if errormessage then --Try again
        print(errormessage)
        local realStats = plr:WaitForChild("realStats")
        local tableToSave = {realStats:WaitForChild("Coins").Value, realStats:WaitForChild("Gems").Value, realStats:WaitForChild("Gifts").Value}
        StatsDataStore:UpdateAsync(plr.UserId, function()
            return tableToSave
        end)
    end
end)
game:BindToClose(function()
    for i,v in next, players:GetPlayers() do
        local success, errormessage = pcall(function()
            local realStats = v:WaitForChild("realStats")
            local tableToSave = {realStats:WaitForChild("Coins").Value, realStats:WaitForChild("Gems").Value, realStats:WaitForChild("Gifts").Value}
            StatsDataStore:UpdateAsync(v.UserId, function()
                return tableToSave
            end)
        end)
        if errormessage then
            local realStats = v:WaitForChild("realStats")
            local tableToSave = {realStats:WaitForChild("Coins").Value, realStats:WaitForChild("Gems").Value, realStats:WaitForChild("Gifts").Value}
            StatsDataStore:UpdateAsync(v.UserId, function()
                return tableToSave
            end)
        end
    end
end)

Can you see anything wrong with it? Thanks.

Shortened the script. Also this is normal DS, not DS2.

This error occurs if you are frequently using SetAsync(). Roblox’s DataStore has a limit. Try reducing the use of SetAsync() or use DataStore2, which is much more effecient. Here is a tutorial on DataStore 2 by AlvinBlox. https://www.youtube.com/watch?v=hBfMfB0BwGA

Hope it helps!

2 Likes

In the code that he is using, I don’t see any SetAsync calls though.

2 Likes

Could you try doing the BindToClose, bit differently? There was a thread by @sjr04 which explained how to use it properly:

1 Like