Data store request was added to queue | DS2

Why i always get an warning message like this :

Untitled

Code :

local DS2 = require(game.ServerScriptService.Settings:WaitForChild("MainModule"))
DS2.Combine("MasterKey", "BodyStats")
    game.Players.PlayerAdded:Connect(function(plr)
    	local dataHead = DS2("BodyStats", plr)


    	local folder = Instance.new("Folder", plr)
    	folder.Name = "BodyStats"

    	local Golden = Instance.new("IntValue", folder)
    	Golden.Name = "Golden"

    	if dataHead:Get() ~= nil then
    		Golden.Value = dataHead:Get()
    	else
    		Golden.Value = 0
    	end
    	

    	Golden.Changed:Connect(function()
    		dataHead:Set(Golden.Value)

    		end)
    	end)

How can i limit this please dont ignore.

1 Like

How often does the the “Golden” value change? If it changes relatively quick then I would look into using an autosave and saving the players data when they leave. You could also add a manual save. So my question is what is the Golden Value and how often does it change?

1 Like

I think every 1 minute because there’s an cooldown however is it possible that causing this message is because im using 1 module for 4 data store stats?

Example :

When the character loaded this will print out thats too mess to see.

1 Like

Not sure what you mean by using 1 module for 4 datastore stats? I assume you mean you have one main module that handles all the stats which is how you should be doing it if your not already.

Yes somethin like that.

1 Main Module
4 Scripts that all connected to 1 Main Module to load and save.

Thats how 1/4

I don’t recommend doing it like that. What I would do is use a table which is far better for saving data, and once you understand it, it is easier to work with.

-- The table should be the default values, Eg. First time a player joins this is what they will have.
local Data_Table = {
    ["Golden"] = 0,
    ["OtherValue"] = 10,
}

local Datastore2 = require() -- Require Datastore2
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local PlayerDataTable = Datastore2("Data",player):GetTable(Data_Table)
    -- Now say for example you want to show a players Golden value;
    print(PlayerDataTable.Golden) -- Prints 0 by default
    PlayerDataTable.Golden = 10 -- Changing the Value
    Datastore2("Data",player):Set(PlayerDataTable) -- Saving the data
end)

I hope this makes sense, and I would highly recommend using tables. However your issue can be solved by making sure there is not that many request by changing the cooldown to a longer duration or by changing the way the data saves and not everytime a value changes. Hopefully this helps and good luck!

1 Like

This usually shows up when your saving data to fast, like other people said I recommend using a table and then saving that table as supposed to doing what you did. Or instead of using Golden.Changed maybe manually save if a player does something, use a while wait() do, or by using a PlayerRemoving function.

(Feel free to mark this as a solution)