What do you want to achieve?
Working DataStore2 system
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
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
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
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
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)
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
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