this is a code datastore, and it always gives me this error after someone redeems a code
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = stats295595864
local data = game:GetService("DataStoreService"):GetDataStore("savedcodes")
local ss = game:GetService("ServerStorage")
local activated = {}
game.Players.PlayerAdded:Connect(function(player)
local key = "codes-"..player.userId
local folder = Instance.new("Folder",player)
folder.Name = "Codes"
local save = data:GetAsync(key)
if save then
for i = 1, #save do
local temp = Instance.new("BoolValue",folder)
temp.Name = save[1]
end
end
end)
game.ReplicatedStorage.Remote.Redeem.OnServerEvent:Connect(function(player,code)
local reward = player:FindFirstChild("leaderstats")
local r = reward.Coins
local key = "codes-"..player.userId
player.PlayerGui:WaitForChild("MainGui"):WaitForChild("Code")
if code == "Code1" then
if player.Codes:FindFirstChild(code) == nil then
local bool = Instance.new("BoolValue")
bool.Parent = player:FindFirstChild("Codes")
bool.Name = code
r.Value = r.Value + 300
player.PlayerGui:FindFirstChild("MainGui").Code.TextBox.Text = "Redeemed!"
wait(2)
player.PlayerGui:FindFirstChild("MainGui").Code.TextBox.Text = ""
else
player.PlayerGui:FindFirstChild("MainGui").Code.TextBox.Text = "Already Redeemed!"
wait(1)
player.PlayerGui:FindFirstChild("MainGui").Code.TextBox.Text = ""
end
end
for i,v in pairs(player.Codes:GetChildren()) do
if v:isA("BoolValue") then
table.insert(activated, v.Name)
data:SetAsync(key,activated)
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
data:SetAsync("codes-"..plr.userId, activated)
end)

4 comments
You need to throttle your data saving. If someone joins the game right on top of you, or you make a request to the same key within 6 seconds, it will throttle the request.
how do I do that? should I use pcall?
The DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests
thats fine unless its an error which then the data doesnt save, u should be fine