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

hello so i got this script

local stat = "Cash" --Change to your stat name
local startamount = 0 --Change to how much points the player will start out with


local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderStatSave")

--Don't worry about the rest of the code, except for line 25.
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Cash = Instance.new("IntValue",leader)
Cash.Name = "Cash"
Cash.Value = ds:GetAsync(player.UserId) or startamount
	ds:SetAsync(player.UserId, Cash.Value)
Cash.Changed:connect(function()
		ds:SetAsync(player.UserId, Cash.Value)
end)
end)

game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) --Change "Points" to the name of your leaderstat.
end)

and for some reason i get this

“DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 3837598027 - Studio” how do i fix this.

1 Like

This part causes that to happen because your basically saving the already saved data and saving the data every time Cash value changes causing too many saves in the short span of time.

So how would i fix that ???

Just save the cash when the player is leaving I would assume

possibly remove that part and only save whenever the player leaves?

How would i do that (sry im bad with datastores)

local stat = "Cash" --Change to your stat name
local startamount = 0 --Change to how much points the player will start out with


local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderStatSave")

--Don't worry about the rest of the code, except for line 25.
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Cash = Instance.new("IntValue",leader)
Cash.Name = "Cash"
Cash.Value = ds:GetAsync(player.UserId) or startamount
end)

game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) --Change "Points" to the name of your leaderstat.
end)

Thank you. it worked (when im done making my game ill put you in the description)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.