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

I’m receiving this error when more of one player is in a server, here is the code:

    local DataStoreService = game:GetService("DataStoreService")
    game.Players.PlayerAdded:Connect(function(player)
	local Effects = Instance.new("Folder",player)
	Effects.Name = "Effects"
	
	local TrailEquipped = Instance.new("StringValue",player)
	TrailEquipped.Name = "TrailEquipped"
	TrailEquipped.Value = ""
	
	local ParticleEquipped = Instance.new("StringValue",player)
	ParticleEquipped.Name = "ParticleEquipped"
	ParticleEquipped.Value = ""
	
	
	for i,v in pairs(game.ReplicatedStorage.Effects:WaitForChild("Trails"):GetChildren()) do
	local Trail = Instance.new("BoolValue",Effects)
	Trail.Name = v.Name
	Trail.Value = DataStoreService:GetDataStore(v.Name):GetAsync(player.userId)
	end
    end)
    game.Players.PlayerRemoving:Connect(function(player)
	for i,v in pairs(game.ReplicatedStorage.Effects:WaitForChild("Trails"):GetChildren()) do
	DataStoreService:GetDataStore(v.Name):SetAsync(player.userId,player.Effects:WaitForChild(v.Name).Value)
	end
      end)

make it player removing only, otherwise, it’d keep doing that error,

also put a wait(1) in the for loop of the player removing thingy, otherwise it’d keep doing that error y’know

I recommend to have both player removing and a timer, as if it fails to save on removing then that entire session is gone. Somewhere between 60-120 seconds is a good amount that won’t cause queues.

but the both for loops will make the data store request drop because there’s way too much requests, thats why there’s a wait(1)

Thats why he should put all his data into a table and save it in 1 datastore

How do I do what you said???

Instead of saving a number or string, you save a table that contains multiple things.

So instead of my having a coin datastore, and an experience datastore, I have a data datastore, which is like

{
     ["Coins"] = 0;
     ["Exp"] = 0;
}

Then you basically use datastores as normal, with this table.

Now, for your case

You have an individual datastore for each effect, when you really only need a table of all the effects. You can use i,v in pairs to insert all the effects into a table, and the value the effect like:

    local DataTable = {}

	for i,v in pairs(game.ReplicatedStorage.Effects:WaitForChild("Trails"):GetChildren()) do
	   DataTable[v.Name] = player.Effects:FindFirstChild(v.Name).Value
    end

And you’d get your table.

And how do I save the table and get async??

You would just do

local Main = DataStoreService:GetDataStore("Main")

--loading data

local DataTable = Main:GetAsync() or {} --if there is no data, use {} which is an empty table

--saving data

Data:SetAsync(DataTable)

Works the exact same as strings and numbers, just with tables.

Thank you for the help! I never used tables before, so thank you very much!

The final code is this:

local DataStoreService = game:GetService("DataStoreService")
local Main = DataStoreService:GetDataStore("Main")

game.Players.PlayerAdded:Connect(function(player)

	local effects = Instance.new("Folder",player)
	effects.Name = "Effects"	
	
	local DataTable = Main:GetAsync(player.userId)
	
	if DataTable then
	
	for i,v in pairs(game.ReplicatedStorage.Effects:WaitForChild("Trails"):GetChildren()) do
		local Trail = Instance.new("BoolValue",effects)
		Trail.Name = v.Name
		Trail.Value = DataTable[v.Name]
		end
	
	else
		
		for i,v in pairs(game.ReplicatedStorage.Effects:WaitForChild("Trails"):GetChildren()) do
			local Trail = Instance.new("BoolValue",effects)
			Trail.Name = v.Name
			Trail.Value = false
		end
		
	end
	

end)

game.Players.PlayerRemoving:Connect(function(player)
	local DataTable = {}
	
	for i,v in pairs(game.ReplicatedStorage.Effects:WaitForChild("Trails"):GetChildren()) do
		DataTable[v.Name] = player.Effects:FindFirstChild(v.Name).Value
        wait(1)
	end
	
	Main:SetAsync(player.userId, DataTable)
end)

With this, i’m gonna have no more “DataStore request was added to queue” ?

1 Like