Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Value Saves But Gets Exhausted?

So my code system is using this to store the values in a folder. The values get stored and it saves but it keeps on saying

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

Code Handler Server Script

local ds = game:GetService("DataStoreService"):GetDataStore("-tCodes01")

game.Players.PlayerAdded:Connect(function(player)
	local key = "codes-"..player.userId
	local folder = Instance.new("Folder",player)
	folder.Name = "Codes"
	local save = ds:GetAsync(key)
	if save then
		for i = 1,#save do
			local temp = Instance.new("BoolValue",folder)
			temp.Name = save[i]
		end
	end
end)

game.ReplicatedStorage.EnterCode.OnServerEvent:Connect(function(player,reward,code,value)
	local key = "codes-"..player.userId
	
	if value == "Gems" then

	local currency = player.MainCurrency:FindFirstChild(value) -- Gems
	currency.Value = currency.Value + reward -- Gems +
	
	elseif value == "Money" then
		
		local currency = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name) -- Money
		local currency = player.MainCurrency:FindFirstChild(value)
		currency.Value = currency.Value + reward -- Money +
	
	end
	
	local bool = Instance.new("BoolValue",player.Codes)
	bool.Name = code
	bool.Value = true
	
	local activated = {}
	for i,v in pairs(player.Codes:GetChildren()) do
		if v:isA("BoolValue") then
			table.insert(activated, v.Name)
			coroutine.wrap(function()
				wait(1)
				
			local success, newData = pcall(function()
				ds:SetAsync(key,activated, 5)
			end)
				if not success then
					warn("CODES NOT SAVED!")
				else
					print('CODES SAVED!')
				end
			end)()
		end
	end
end)

1 comment

0

Any Ideas How To Fix This?

1 answer

Oops, I figured out what I did wrong lol. I just had the wrong name in the local script that fires the event o-0

This discussion is preserved as it was. New answers, comments, and votes are closed.