Hello,
Recently I made a quick saving leaderstats script which works fine.
Problems arose when I wanted to add a certain number of points to a player (adding points script)
When the player repeats this command several times, this message is displayed on the output:
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 451472157
When the command repeats approximately 24 times, the writer stops working.
Saving leaderstats script
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("MoneyStats")
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder", plr)
folder.Name = "Leaderstats"
local currency = Instance.new("IntValue", folder)
currency.Name = "Money"
currency.Value = ds:GetAsync(plr.UserId) or 0
currency.Changed:Connect(function()
ds:SetAsync(plr.UserId, currency.Value)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
ds:SetAsync(plr.UserId, plr.Leaderstats.Money.Value)
end)
Adding points script
plr.Leaderstats.Money.Value = plr.Leaderstats.Money.Value+1
I tried to change some script elements, e.g. change it to local script or add RemoteEvent, but it didn’t make sense.
What should I do?