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.
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!