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

Hi im not really good with data store i cant find any problem in this script
please help me find the problem

local dataservice = game:GetService("DataStoreService")
local mydata = dataservice:GetDataStore("PlayerData")

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	
	local Finish = Instance.new("IntValue")
	Finish.Parent = plr
	Finish.Name = "Finish"
	
	local MazeBux = Instance.new("IntValue")
	MazeBux.Parent = leaderstats
	MazeBux.Name = "MazeBux"
	
	local Rank = Instance.new("StringValue")
	Rank.Parent = leaderstats
	Rank.Name = "Rank"
	Rank.Value = "Maze Noobie"
	
	local plrId = plr.UserId
	local data
	
	local s, e pcall(function()
		data = mydata:GetAsync(plrId)
	end)
	if s then
		Rank.Value = data.Rank
		MazeBux.Value = data.Bux
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local dataToSave = {
		Rank = plr.leaderstats.Rank.Value;
		Bux = plr.leaderstats.MazeBux.Value
	}
	print(dataToSave.Rank)
	print(dataToSave.Bux)
	local plrId = plr.UserId
	print(plrId)
	local s, e pcall(function()
		mydata:SetAsync(plr.UserId, dataToSave)
	end)
	if s then
		print(s)
		print("Data SuccessFully saved")
	else 
		print(e)
		print("Failed")
	end
end)

game:BindToClose(function()
	for i, plr in pairs(game.Players:GetChildren())do
		local dataToSave = {
			Rank = plr.leaderstats.Rank.Value;
			Bux = plr.leaderstats.MazeBux.Value
		}
		local plrId = plr.UserId
		print(plrId)
		local s, e pcall(function()
			mydata:SetAsync(plrId, dataToSave)
		end)
		if s then
			print("Data SuccessFully saved")
		else 
			print("Failed")
		end
	end
end)
1 Like

You are trying to save a table. DSS is designed to save string or integers.
If the data is unable to save then it can cause your que to fill up.

Are you using free models on your game like admin commands or stuff? because they can overload the queue of datastore because they can be poorly scripted.

Other than that you might want convert your table using JSONEncode that is in Httpservice and save it then use jsondecode to get it back.

so how do you fix it???

Hey, you’re mistaken here. You can save tables. The error is basically that the OP is sending too much datastore requests at a time, and thus DataStore is slowing down.

According to the DevHub, I quote:

6 seconds between write requests

If it would be invalid data, it would error, not warn, and it’d be a Code 103/104.

Source: https://developer.roblox.com/en-us/articles/Datastore-Errors

@supercronter4, you’re sending too much requests. Check if you don’t have models/scripts that send useless datastore requests, and make sure there is only this script sending DataStore.

1 Like

Tables work in DataStore, no need to use JSON which would just slow down code.

local dataservice = game:GetService("DataStoreService")
local mydata = dataservice:GetDataStore("PlayerData")

mydata:SetAsync("Wow", {
	["A table"] = "works in datastore",
	["and the proof"] = "is this example",
	["gataou"] = 4
})

Output:
image