DataStore2 Warning/Error

  1. What do you want to achieve?
    Working DataStore2 system
  2. What is the issue?
    Warning/Error : DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = index
  3. What solutions have you tried so far?
    I tried looking on other forum posts… either im blind or it isnt anywhere

This is the script:

local datastore2 = require(game.ServerScriptService:WaitForChild("DataStore2"))
datastore2.Combine("DATAKEY", "MoneySave",  "PoliceXP",  "EMSXP",  "FireXP" ,  "CriminalXP")


local defaultPoliceXP = 1
local defaultEMSXP = 1
local defaultCriminalXP = 1
local defaultFireXP = 1
local defaultCashValue = 50




game.Players.PlayerAdded:Connect(function(plr)
	local dscash = datastore2("MoneySave", plr)
	local dspolicexp = datastore2("PoliceXP", plr)
	local dsemsxp = datastore2("EMSXP", plr)
	local dsfirexp = datastore2("FireXP", plr)
	local dscriminalxp = datastore2("CriminalXP", plr)

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

	local currency = Instance.new("IntValue", leader)
	currency.Name = "Cash"

	local policexp = Instance.new("IntValue", leader)
	policexp.Name = "PoliceXP"

	local emsxp = Instance.new("IntValue", leader)
	emsxp.Name = "EMSXP"

	local firexp = Instance.new("IntValue", leader)
	firexp.Name = "FireXP"

	local criminalxp = Instance.new("IntValue", leader)
	criminalxp.Name = "CriminalXP"

	local updateCashValue = function(updatedCashValue)
		currency.Value = dscash:Get(updatedCashValue)
	end
	updateCashValue(defaultCashValue)
	dscash:OnUpdate(updateCashValue)


	local updatePoliceValue = function(updatedPoliceValue)
		policexp.Value = dspolicexp:Get(updatedPoliceValue)
	end
	updatePoliceValue(defaultPoliceXP)
	dspolicexp:OnUpdate(updatePoliceValue)

	local updateFireValue = function(updatedFireValue)
		firexp.Value = dsfirexp:Get(updatedFireValue)
	end
	updateFireValue(defaultFireXP)
	dsfirexp:OnUpdate(updateFireValue)

	local updateEmsValue = function(updatedEmsValue)
		emsxp.Value = dsemsxp:Get(updatedEmsValue)
	end
	updateEmsValue(defaultEMSXP)
	dsemsxp:OnUpdate(updateEmsValue)

	local updateCriminalValue = function(updatedCriminalValue)
		criminalxp.Value = dscriminalxp:Get(updatedCriminalValue)
	end
	updateCriminalValue(defaultCriminalXP)
	dscriminalxp:OnUpdate(updateCriminalValue)
end)

Only other scripts that has to do anything with these values are just LocalScripts inside TextLabels so i can show players their values

1 Like

Definitely have no idea how DataStore2 works haha but I know the warning

In short: You’re sending too much requests for the script to handle, DataStores have limits depending on how frequent you update/save the data

I’m guessing the error may lie around here’ish:

	local updateCashValue = function(updatedCashValue)
		currency.Value = dscash:Get(updatedCashValue)
	end
	updateCashValue(defaultCashValue)
	dscash:OnUpdate(updateCashValue)


	local updatePoliceValue = function(updatedPoliceValue)
		policexp.Value = dspolicexp:Get(updatedPoliceValue)
	end
	updatePoliceValue(defaultPoliceXP)
	dspolicexp:OnUpdate(updatePoliceValue)

	local updateFireValue = function(updatedFireValue)
		firexp.Value = dsfirexp:Get(updatedFireValue)
	end
	updateFireValue(defaultFireXP)
	dsfirexp:OnUpdate(updateFireValue)

	local updateEmsValue = function(updatedEmsValue)
		emsxp.Value = dsemsxp:Get(updatedEmsValue)
	end
	updateEmsValue(defaultEMSXP)
	dsemsxp:OnUpdate(updateEmsValue)

	local updateCriminalValue = function(updatedCriminalValue)
		criminalxp.Value = dscriminalxp:Get(updatedCriminalValue)
	end

If this is a Changed Event, that’s probably why you’re getting that warning since you’re updating it so frequently

2 Likes

OnUpdate are events set to the individual DataStore keys to run when the data changed

@FlyingMikee Where is it updating the data? Could you show us the code that changes the data of those datastores? Aka, code taht increases or decreases those values

2 Likes

This is the code:
local datastore2 = require(game.ServerScriptService:WaitForChild(“DataStore2”))
datastore2.Combine(“DATAKEY”, “MoneySave”, “PoliceXP”, “EMSXP”, “FireXP” , “CriminalXP”)

game.Players.PlayerAdded:Connect(function(player)
	while true do
		wait(3)
		local cashStore = datastore2("MoneySave", player)
		cashStore:Increment(1)

	end
end)

but the problem is it does this error even if im not updating any value at all

but here are the local scripts:

local player = game.Players.LocalPlayer

while true do

wait(1)

script.Parent.Text = player.leaderstats.Cash.Value .. " $"

end

 ` local player = game.Players.LocalPlayer`
        local policexp = player.leaderstats.PoliceXP.Value
        local firexp = player.leaderstats.FireXP.Value
        local criminalxp = player.leaderstats.CriminalXP.Value
        local emsxp = player.leaderstats.EMSXP.Value


while true do
	wait(1)
	if player.Team == game.Teams.BHPD then
		if policexp > -1 and policexp < 500 then
			script.Parent.Text = "Cadet"
		end
	end
	if player.Team == game.Teams.BHFD then
		if policexp > -1 and firexp < 500 then
			script.Parent.Text = "Fireman"
		end
	end
	if player.Team == game.Teams["BH-EMS"] then
		if policexp > -1 and emsxp < 500 then
			script.Parent.Text = "Medic"
		end
	end
	if player.Team == game.Teams.Criminal then
		if policexp > -1 and criminalxp < 500 then
			script.Parent.Text = "Small theif"
		end
	end
	if player.Team == game.Teams.Citizen then
		script.Parent.Text = ""
	end
end

local player = game.Players.LocalPlayer

while true do
	wait(1)
	if player.Team == game.Teams.BHPD then
		script.Parent.Text = player.leaderstats.PoliceXP.Value
	end
	if player.Team == game.Teams["BH-EMS"] then
		script.Parent.Text = player.leaderstats.EMSXP.Value
	end
	if player.Team == game.Teams.BHFD then
		script.Parent.Text = player.leaderstats.FireXP.Value
	end
	if player.Team == game.Teams.Criminal then
		script.Parent.Text = player.leaderstats.CriminalXP.Value
	end
	if player.Team == game.Teams.Citizen then
		script.Parent.Text = ""
	end
end

I think the problem might be here because im constantly checking the value
(these are localscripts under textlabels)

1 Like

You’re updating their cash every 3 seconds, you’re sending 20 requests a minute per player, increase the time

2 Likes

Yep, im dumb… i didnt realise that code should’ve been only for testing purposes. BUT it still says that error even when i deleted every increment script in the game. I dont understand… also it was working fine yesterday today I opened up Roblox Studio i didnt change anything and it suddenly started saying this

1 Like

Okay so… I literally deleted everything in that game so there is only baseplate and that stupid script and its still saying that error… im so confused

I think you may’ve done something problamatic in the DS2 script that I can’t see, maybe try this?

local datastore2 = require(game.ServerScriptService:WaitForChild("DataStore2"))
datastore2.Combine("DATAKEY", "MoneySave",  "PoliceXP",  "EMSXP",  "FireXP" ,  "CriminalXP")

local defaultPoliceXP = 1
local defaultEMSXP = 1
local defaultCriminalXP = 1
local defaultFireXP = 1
local defaultCashValue = 50

game.Players.PlayerAdded:Connect(function(plr)
	local dscash = datastore2("MoneySave", plr)
	local dspolicexp = datastore2("PoliceXP", plr)
	local dsemsxp = datastore2("EMSXP", plr)
	local dsfirexp = datastore2("FireXP", plr)
	local dscriminalxp = datastore2("CriminalXP", plr)

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

	local currency = Instance.new("IntValue", leader)
	currency.Name = "Cash"
	currency.Value = dscash:Get(defaultCashValue)

	local policexp = Instance.new("IntValue", leader)
	policexp.Name = "PoliceXP"
	policexp.Value = dspolicexp:Get(defaultPoliceXP)

	local emsxp = Instance.new("IntValue", leader)
	emsxp.Name = "EMSXP"
	emsxp.Value = dsemsxp:Get(defaultEMSXP)

	local firexp = Instance.new("IntValue", leader)
	firexp.Name = "FireXP"
	firexp.Value = dsfirexp:Get(defaultFireXP)

	local criminalxp = Instance.new("IntValue", leader)
	criminalxp.Name = "CriminalXP"
	criminalxp.Value = dscriminalxp:Get(defaultCriminalXP)

	local updateCashValue = function(updatedCashValue)
		currency.Value = updatedCashValue
	end
	dscash:OnUpdate(updateCashValue)

	local updatePoliceValue = function(updatedPoliceValue)
		policexp.Value = updatedPoliceValue
	end
	dspolicexp:OnUpdate(updatePoliceValue)

	local updateFireValue = function(updatedFireValue)
		firexp.Value = updatedFireValue
	end
	dsfirexp:OnUpdate(updateFireValue)

	local updateEmsValue = function(updatedEmsValue)
		emsxp.Value = updatedEmsValue
	end
	dsemsxp:OnUpdate(updateEmsValue)

	local updateCriminalValue = function(updatedCriminalValue)
		criminalxp.Value = updatedCriminalValue
	end
	dscriminalxp:OnUpdate(updateCriminalValue)
end)

You already get the latest value from onupdate, no need to make a call to the datastore

1 Like

Nope, nothing… :frowning: Maybe it has to do something with my internet conection because earlier this morning i had some problems with connecting

umm… it does that warning even when i deleted that script completely… so i have just baseplate and its still doing that… is it supposed to be like that? because im confused

The warning does not mean nothing much you can search it here on DevForum and I don’t think it can affect player data correct me if I am wrong.

1 Like

Yeah i think the same thing because it saves the data but I am just worried about data loss and stuff like that…

No dont worry about it you are safe.

1 Like