Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Roblox DataStore - Requested was Throttled. Try sending fewer requests?

Asked by 6 years ago

So I have a datastore here is my code:

local DataStore = game:GetService("DataStoreService")
local Ds = DataStore:GetDataStore("PlayerValueSave")

game.Players.PlayerAdded:Connect(function(player)
    local stats = Instance.new("IntValue", player)
    stats.Name = "leaderstats"

    local Money = Instance.new("IntValue", stats)
    Money.Name = "Money"
    Money.Value = Ds:GetAsync(player.UserId) or 100

    local Role = Instance.new("StringValue", stats)
    Role.Name = "Rank"
    Role.Value = "Owner"

    Ds:SetAsync(player.UserId, Money.Value)
    Money.Changed:Connect(function()
        Ds:SetAsync(player.UserId, Money.Value)
    end)
end)

game.Players.PlayerRemoving:Connect(function(player)
    Ds:SetAsync(player.UserId, player.leaderstats.Money.Value)
end)

game.Workspace.Baseplate.BrickColor = BrickColor.Black()

I have a textbutton that has a localscript, that is changing the players value of their money by using RemoteEvents to do so.

But I am getting this odd error, "Request was Throttled, try sending fewer requests" and SetAsync request was dropped. Request was Throttled, but throttled request queue was full.

The SetAsync error is revolving around Line 18. The first error (Try sending fewer requests) doesn't specify a line. It's the orangish text.

0
The Datastore doesnt work in studio Try it ingame adamdeno 2 — 6y
0
"facepalm", I am doing it in-game. Of course, I'm not that non intelligent to know that it won't work in studio. To put it simple, yes I have tested it on my own game. But I have opened my developer console in game aswell and I have gone to the server log to find and discover those errors. User#21998 0 — 6y
0
Maybe try to make stats with their own save? i usually go with scriptsavemoney , scriptsaveXP , scriptsavelevel Its probably cuz it can only allow one stat to be saved? i dunno but try to set 1 stat for each save? try it i dont know i am new to lua thingy adamdeno 2 — 6y
0
I'm only saving one stat, and that's the Money interger value. :P User#21998 0 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

The problem is that whenever the money changes you are saving an amount. This wouldn't be a problem except for the fact that roblox limits how many datastore requests you can send per specified amount of time. I actually don't know exactly what the limit is off the top of my head. However, this means that if the players money changes twice in a second or two seconds, that it will throttle the request. So my recommendation is to not Connect a datastore request with a changed event. What you should do instead is save when they leave and, if you wish, save in a while loop every few minutes or so. I hope this helps and have a great day scripting!

0
I added a wait call and it seems to be fixing this error, so Money.Changed:Connect(function() wait(10) Ds:SetAsync(player.UserId, Money.Value) end) User#21998 0 — 6y
Ad

Answer this question