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

So i’m kind of new to this Data store thing and i was getting this in the output and i was wondering what it is and should i worry about it

i would appreciate if someone could help me out Thank u :smiley:

Here is the code:

local DataStore = game:GetService("DataStoreService")
local Data = DataStore:GetDataStore("Cropv10")

local RS = game:GetService("ReplicatedStorage")
local Builder = RS:FindFirstChild("Crops")
local function GetCrop(player)
	coroutine.resume(coroutine.create(function()
		
	for i,v in pairs(player.Crops:GetChildren()) do
			local Items = Data:GetAsync(player.UserId)
			print("Starting")
			if Items then
				
				for i,item in pairs(Items) do
					
					local ItemName = item[1]
					print(ItemName)
				
					local CloneItem = Builder:FindFirstChild(ItemName):Clone()
					CloneItem.Parent = player:WaitForChild("Crops")
					

				end
			
			return
	end
	end
	end))
end

local function GrabCrop(player)
	coroutine.resume(coroutine.create(function()
	for i,v in pairs(player.Crops:GetChildren()) do
			
			local Items = {}
			for i,item in pairs(player.Crops:GetChildren()) do
			if item:IsA("Part") or item:IsA("MeshPart") then
				
				print("Saving")		
					table.insert(Items,{item.Name,{}})
						
							

end
			end
			wait()
			Data:SetAsync(player.UserId,Items)
		end
	
	end))
end

game.Players.PlayerAdded:Connect(function(Player)
	wait(3)
	GetCrop(Player)
end)

game.Players.PlayerRemoving:Connect(function(Player)
	GrabCrop(Player)
end)

11 Likes

i just noticed it only happens when i save multiple parts because i tried saving one part and there was nothing but when i tried saving five parts i get this
btw im using this to save parts

2 Likes

Looking at the warning, it seems that you’re saving to the same key too frequently. if you’re using SetAsync, you’re supposed to have 6-second cooldown between each call. How are you saving the data? Can you show the code?

2 Likes

Yeah i just edited the post you can see the code now

2 Likes

I can see the error now:

for i,v in pairs(player.Crops:GetChildren()) do
			
	local Items = {}
	for i,item in pairs(player.Crops:GetChildren()) do
		if item:IsA("Part") or item:IsA("MeshPart") then	
			print("Saving")		
			table.insert(Items,{item.Name,{}})			
        end
	end
	wait()
	Data:SetAsync(player.UserId,Items) -- This line
end

Try putting it outside of the loop:

for i,v in pairs(player.Crops:GetChildren()) do
			
	local Items = {}
	for i,item in pairs(player.Crops:GetChildren()) do
		if item:IsA("Part") or item:IsA("MeshPart") then	
			print("Saving")		
			table.insert(Items,{item.Name,{}})			
        end
	end
	wait()
end
Data:SetAsync(player.UserId,Items) -- Hi I'm here now

This is just a nitpick of your code:

table.insert(Items,{item.Name,{}})

Change that to:

table.insert(Items[item.Name], item)
15 Likes

The issue is you’re saving the data every iteration, and each call does not have a 6-second cooldown between them, hence why the warning happens. This is called request throttling, and it’s really nothing to worry about, since the request will be in a queue and will eventually be handled; however as mentioned, if the request queue is filled and you want to make more requests, those requests will be dropped

If you want to fix this, @VegetationBush’s solution should do the trick. Although request throttling is nothing to worry over, you should still try to minimise the amount of requests so that the chance of some requests not being handled will be reduced

7 Likes

so about the table.insert so the table is in the loop so i had to put outside of the loop but when i did that i got this error
ServerScriptService.CropsSaver:39: bad argument #1 (table expected, got nil)

2 Likes

Yes it did but now i have this error when i moved the table outside of the loop

[ ServerScriptService.CropsSaver:39: bad argument #1 (table expected, got nil)]

2 Likes

What is the code you have on line 39 in the script?

2 Likes
table.insert(Items[item.Name], item)
2 Likes

I see you use arrays to store/get the data, so with respect to that this should do the trick.

table.insert(Items, item.Name)
4 Likes

Yes now it works thanks alot :+1:

3 Likes