Hi, I am making a game with a daily reward system. It is constantly saying: DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 792800740
I had two scripts that says GetDataStore, so I tried to make 1 script, with 1 GetDataStore, but it didn't worked...
Please help, someone :(
here is the code:
local DataStore = game:GetService("DataStoreService"):GetDataStore("PointLeaderStatsSaverKnobbyObby")
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "leaderstats"
local currency = Instance.new("IntValue", folder)
currency.Name = "Points"
currency.Value = DataStore:GetAsync(plr.UserId) or 0
currency.Changed:Connect(function()
DataStore:SetAsync(plr.UserId, currency.Value)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
DataStore:SetAsync(plr.UserId, plr.leaderstats.Points.Value)
end)
local hourWait = 24
local possibleRewards = {10,15,10,10,10,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,10,10,15,15,500}
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = player:WaitForChild("leaderstats")
local timeNow = os.time()
local data
pcall(function()
data = DataStore:GetAsync(player.UserId.."-dailyRewards")
print("Getting Data")
end)
if data ~= nil then
-- Returning player to the game
local timeSinceLastClaim = timeNow - data -- Number in sec since the last reward was claimed
print("Time since last claim "..timeSinceLastClaim)
if (timeSinceLastClaim / 3600) >= hourWait then
-- They are eligible for a reward
local reward = possibleRewards[math.random(1,#possibleRewards)]
game.ReplicatedStorage.ShowDailyReward:FireClient(player,hourWait,reward)
local connection
connection = game.ReplicatedStorage.ClaimReward.OnServerEvent:Connect(function(triggeringPlayer)
if triggeringPlayer == player then
print("Reward Claimed")
player.leaderstats.Points.Value = player.leaderstats.Points.Value + reward
DataStore:SetAsync(player.UserId.."-dailyReward",os.time())
connection:Disconnect()
end
end)
else
print("Player is uneligible right now")
end
else
-- New player
print("New Player")
local reward = possibleRewards[math.random(1,#possibleRewards)]
game.ReplicatedStorage.ShowDailyReward:FireClient(player,hourWait,reward)
local connection
connection = game.ReplicatedStorage.ClaimReward.OnServerEvent:Connect(function(triggeringPlayer)
if triggeringPlayer == player then
print("Reward Claimed")
player.leaderstats.Points.Value = player.leaderstats.Points.Value + reward
DataStore:SetAsync(player.UserId.."-dailyReward",os.time())
connection:Disconnect()
end
end)
end
end)
Ps: If my English is bad, I am from another country.

5 comments
I can't find any loop. I've added the code. Thanks for your answer!
Your error is most likely in lines 9 and 10, you're setting the datastore every single time the change function is called, that can cause a ton of requests depending on how often it's changed
Do you know how I can save the player's leaderstats, but without the error?
I would just set it when the player is removing rather than every time it changes
Ok! Thank you very much!! :)