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

  1. What do you want to achieve?

I keep getting an error showing “DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Data Store”

  1. What is the issue?
    Every time I load into my game it keeps showing that error

  2. What solutions have you tried so far?
    Looking for a solution

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStoreV3")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Coins = Instance.new("NumberValue", leaderstats)
	Coins.Name = "Coins"
	Coins.Parent = leaderstats
	Coins.Value = 0
	
	local donates = Instance.new("IntValue")
	donates.Name = "R$ Donated"
	donates.Parent = player
	donates.Value = 0

	local DJumps = Instance.new("NumberValue",player)
	DJumps.Name = "DJumps"

	local MaxJumps = Instance.new("NumberValue",DJumps)
	MaxJumps.Name = "MaxDJumps"
	MaxJumps.Value = 1

	local Boost = Instance.new("NumberValue",DJumps)
	Boost.Name = "Boost"
	Boost.Value = MaxJumps.Value

	local Need = Instance.new("NumberValue",DJumps)
	Need.Name = 'Need'
	Need.Value = 100

	local Strength = Instance.new("NumberValue", leaderstats)
	Strength.Name = "Strength"
	Strength.Parent = leaderstats
	Strength.Value = 0

	local Capacity = Instance.new("NumberValue", player)
	Capacity.Name = "Capacity"
	Capacity.Parent = player
	Capacity.Value = 10

	local Diamonds = Instance.new("NumberValue", leaderstats)
	Diamonds.Name = "Diamonds"
	Diamonds.Parent = leaderstats
	Diamonds.Value = 0

	local Rank = Instance.new("IntValue", leaderstats)
	Rank.Name = "Rank"
	Rank.Parent = leaderstats
	Rank.Value = "MiniFlyWeight"
	
	local Level = Instance.new("NumberValue")
	Level.Name = "Level"
	Level.Parent = player
	Level.Value = 1
	
	local Exp = Instance.new("NumberValue")
	Exp.Name = "Exp"
	Exp.Parent = Level
	Exp.Value = 0
	
	local MaxExp = Instance.new("NumberValue")
	MaxExp.Name = "MaxExp"
	MaxExp.Parent = Level
	MaxExp.Value = 100
	
	Strength.Changed:Connect(function()
		if Strength.Value >= Capacity.Value then
			Strength.Value = Capacity.Value
		end
	end)
	
	Exp.Changed:Connect(function(Val)
		if Exp.Value >= MaxExp.Value then
			
			
			Level.Value = Level.Value + 1
			Exp.Value = 0
			MaxExp.Value = MaxExp.Value + 10
		end
	end)

	local key = player.UserId

	local data
	local success,msg = pcall(function()
		data = DataStore:GetAsync(key)
	end)

	if data then
		print("Data Loaded")
		Strength.Value = data.S
		Capacity.Value = data.C
		Rank.Value = data.R
		Diamonds.Value = data.D
		Coins.Value = data.Cs
		MaxJumps.Value = data.M
		Need.Value = data.N
		Level.Value = data.L
		Exp.Value = data.E
		MaxExp.Value = data.m
		donates.Value = data.d
	else
		print("Error")
		warn(msg)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local key = player.UserId

	local data = {
		C = player.Capacity.Value,
		Cs = player.leaderstats.Coins.Value,
		S = player.leaderstats.Strength.Value,
		D = player.leaderstats.Diamonds.Value,
		R = player.leaderstats.Rank.Value,
		M = player.DJumps.MaxDJumps.Value,
		N = player.DJumps.Need.Value,
		L = player.Level.Value,
		E = player.Level.Exp.Value,
		m = player.Level.MaxExp.Value,
		d = player.leaderstats.donates.Value,
	}

	local success,msg = pcall(function()
		DataStore:SetAsync(key,data)
	end)

	if success then
		print("Data Saved!")
	end
end)
game.ReplicatedStorage:WaitForChild("Boost").OnServerEvent:Connect(function(player)

	if player.leaderstats.Coins.Value >= player.DJumps.Need.Value  then
		player.leaderstats.Coins.Value -= player.DJumps.Need.Value
		player.DJumps.Need.Value *= 10
		player.DJumps.MaxDJumps.Value += 1
		print(player.DJumps.MaxDJumps.Value)
	else
		print("Not Enough Coins!")
	end
end)
3 Likes

If anyone finds a solution please let me know

1 Like

I think it’s because there is too much data to load…

1 Like

You are saving the data way too fast. Datastores have a limit.

Try to save all the data every x seconds instead of every time the value changes (or save when the player leaves the game)

These are the datastore limits

1 Like

So would I just have to add a wait()

1 Like

You should save the value with a table , something like that when you save

local Data = {
["StatsName1"] = plr.StatsName1;
["StatsName2"] = plr.StatsName2;
}

and when you load , to get the stat just use plr.StatsName1 = Data.StatsName1 or 0

1 Like

Would it be something like this

local key = player.UserId

	local data
	local success,msg = pcall(function()
		data = DataStore:GetAsync(key)
	end)

	if data then
		print("Data Loaded")
	else
		print("Error")
		warn(msg)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local key = player.UserId

	local data = {
		["Capacity"] = player.Capacity,
	}

	local success,msg = pcall(function()
		DataStore:SetAsync(key,data)
	end)

	if success then
		print("Data Saved!")
	end
end)
1 Like

This shouldn’t fix the error message, the problem is that you do too many SetAsync or GetAsync requests. Is this the only script you do data saving in?

1 Like

in wich script do you have this error?

Wait nvm that was a wrong script I just deleted it


This is the error that keeps showing in the output

I think i found a fix, i have to do something real quick tho. Ill get back ASAP!

Ok thank you, don’t worry though!

Okay so in both the datastore and leaderboard script you save something with the same UserId when a player leaves.
Due to roblox their datastore limits, there HAS to be a 6 second interval between saving with the same key

So for example:

image

Since the leaderboard datastore is different from the normal datastore you can just change their keys.
In the normal datastore you save with the player.UserId.
And in the leaderboard datastore you save with for example "leaderboard_"..player.UserId. Since they both have different keys, it will not hit the datastore limits

Do not forget to also use the same key used when doing :GetAsync()

1 Like

If you want to be ~100% safe from getting annoying errors you can also take a look at different saving methods like:

1 Like

Try this:

local datastoreservice = game:GetService("DataStoreService")
local datastore = datastoreservice:GetOrderedDataStore("leaderboarddatastore")

local player = game:GetService("Players")

local coinsleaderboard = workspace:WaitForChild("Coinsleaderboard")

local frame = coinsleaderboard:WaitForChild("SurfaceGui"):WaitForChild("Frame"):WaitForChild("ScrollingFrame")
local UIGridLayout = frame:WaitForChild("UIGridLayout")

local tempclone = script:WaitForChild("Temp")

local playerisingame = {}

local function newplayer(player)

	local leaderstats = Instance.new("Folder", player)
	leaderstats.Name = "leaderstats"

	local Coins = Instance.new("NumberValue", leaderstats)
	Coins.Name = "Coins"

	local coinsdata
	pcall(function()
		coinsdata = datastore:GetAsync(player.UserId.."_leaderboard")
	end)
	if coinsdata ~= nil then
		Coins.Value = coinsdata
	end
end

local function Updateguileaderboard()

	local pages
	pcall(function()
		pages = datastore:GetSortedAsync(false,10)
	end)
	if pages ~= nil then
		local currentpage = pages:GetCurrentPage()

		for i, v in pairs(frame:GetChildren()) do
			if v:IsA("Frame") then
				v:Destroy()
			end
		end

		for i, data in ipairs(currentpage) do
			local username
			pcall(function()
				username = player:GetNameFromUserIdAsync(data["key"])
			end)
			if username ~= nil then
				local tempframe = tempclone:Clone()
				tempframe.Parent = frame
				tempframe:WaitForChild("Rank").Text = "#"..i
				tempframe:WaitForChild("Player").Text = username
				tempframe:WaitForChild("Coins").Text = data["value"]
			end
		end
		local size = Vector2.new(1, 0.1) * frame.AbsoluteSize
		UIGridLayout.CellSize = UDim2.new(0, size.X, 0, size.Y)
		frame.CanvasSize = UDim2.new(0, 0, 0, UIGridLayout.AbsoluteContentSize.Y)
	end
end

local function playerremoving(player)
	playerisingame[player] = nil

	pcall(function()
		local tempcoins = player:WaitForChild("leaderstats"):WaitForChild("Coins").Value
		if tempcoins >= 1 then
			datastore:SetAsync(player.UserId.."_leaderboard", tempcoins)
			Updateguileaderboard()
		end
	end)
end

player.PlayerAdded:Connect(function(player)
	if playerisingame[player] == nil then
		newplayer(player)
	end
end)

playerisingame = player:GetPlayers()

for i, v in pairs(playerisingame) do
	newplayer()
end

player.PlayerRemoving:Connect(playerremoving)
Updateguileaderboard()
1 Like

I am still confused how to change it in me script

1 Like

Thats the wrong script I sent before I deleted that script this is script that I am using

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStoreV3")

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder",player)
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local Coins = Instance.new("NumberValue", leaderstats)
	Coins.Name = "Coins"
	Coins.Parent = leaderstats
	Coins.Value = 0
	
	local donates = Instance.new("IntValue")
	donates.Name = "R$ Donated"
	donates.Parent = player
	donates.Value = 0

	local DJumps = Instance.new("NumberValue",player)
	DJumps.Name = "DJumps"

	local MaxJumps = Instance.new("NumberValue",DJumps)
	MaxJumps.Name = "MaxDJumps"
	MaxJumps.Value = 1

	local Boost = Instance.new("NumberValue",DJumps)
	Boost.Name = "Boost"
	Boost.Value = MaxJumps.Value

	local Need = Instance.new("NumberValue",DJumps)
	Need.Name = 'Need'
	Need.Value = 100

	local Strength = Instance.new("NumberValue", leaderstats)
	Strength.Name = "Strength"
	Strength.Parent = leaderstats
	Strength.Value = 0

	local Capacity = Instance.new("NumberValue", player)
	Capacity.Name = "Capacity"
	Capacity.Parent = player
	Capacity.Value = 10

	local Diamonds = Instance.new("NumberValue", leaderstats)
	Diamonds.Name = "Diamonds"
	Diamonds.Parent = leaderstats
	Diamonds.Value = 0

	local Rank = Instance.new("IntValue", leaderstats)
	Rank.Name = "Rank"
	Rank.Parent = leaderstats
	Rank.Value = "MiniFlyWeight"
	
	local Level = Instance.new("NumberValue")
	Level.Name = "Level"
	Level.Parent = player
	Level.Value = 1
	
	local Exp = Instance.new("NumberValue")
	Exp.Name = "Exp"
	Exp.Parent = Level
	Exp.Value = 0
	
	local MaxExp = Instance.new("NumberValue")
	MaxExp.Name = "MaxExp"
	MaxExp.Parent = Level
	MaxExp.Value = 100
	
	Strength.Changed:Connect(function()
		if Strength.Value >= Capacity.Value then
			Strength.Value = Capacity.Value
		end
	end)
	
	Exp.Changed:Connect(function(Val)
		if Exp.Value >= MaxExp.Value then
			
			
			Level.Value = Level.Value + 1
			Exp.Value = 0
			MaxExp.Value = MaxExp.Value + 10
		end
	end)

	local key = player.UserId

	local data
	local success,msg = pcall(function()
		data = DataStore:GetAsync(key)
	end)

	if data then
		print("Data Loaded")
		Strength.Value = data.S
		Capacity.Value = data.C
		Rank.Value = data.R
		Diamonds.Value = data.D
		Coins.Value = data.Cs
		MaxJumps.Value = data.M
		Need.Value = data.N
		Level.Value = data.L
		Exp.Value = data.E
		MaxExp.Value = data.m
		donates.Value = data.d
	else
		print("Error")
		warn(msg)
	end
end)

game.Players.PlayerRemoving:Connect(function(player)
	local key = player.UserId

	local data = {
		C = player.Capacity.Value,
		Cs = player.leaderstats.Coins.Value,
		S = player.leaderstats.Strength.Value,
		D = player.leaderstats.Diamonds.Value,
		R = player.leaderstats.Rank.Value,
		M = player.DJumps.MaxDJumps.Value,
		N = player.DJumps.Need.Value,
		L = player.Level.Value,
		E = player.Level.Exp.Value,
		m = player.Level.MaxExp.Value,
		d = player.leaderstats.donates.Value,
	}

	local success,msg = pcall(function()
		DataStore:SetAsync(key,data)
	end)

	if success then
		print("Data Saved!")
	end
end)
game.ReplicatedStorage:WaitForChild("Boost").OnServerEvent:Connect(function(player)

	if player.leaderstats.Coins.Value >= player.DJumps.Need.Value  then
		player.leaderstats.Coins.Value -= player.DJumps.Need.Value
		player.DJumps.Need.Value *= 10
		player.DJumps.MaxDJumps.Value += 1
		print(player.DJumps.MaxDJumps.Value)
	else
		print("Not Enough Coins!")
	end
end)

Is this the only script that is doing datastore related things in your game now?

Sorry if I am confusing you but that is the script that I think keeps giving the errors