So I’m trying to make an equip system and when I set async a table value of an inventory it gave me the message: “DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = Player_185041318.” This is the line and it’s not a repeating line because when I printed a message it only printed once.
game.ReplicatedStorage.Events.EquipUnit.OnServerEvent:Connect(function(p, units)
game.ReplicatedStorage.Events.EquipUnit:FireClient(p, units)
table.clear(inven) -- inven is the inventory table
for i,v in pairs(units) do
table.insert(inven, v)
end
inv:SetAsync("Player_" .. p.UserId, inven) -- I printed a message and it only printed once
end)
If updateAsync is the answer, then how should I use it?
UpdateAsync has certain benefits over SetAsync, but you have to actually use them. Code that does not leverage the old data might as well be using SetAsync. There are threads explaining how to use UpdateAsync separately, such as the one below, but overall use SetAsync for quick and dirty saving and UpdateAsync for careful operations taking previous data into account.
Never use UpdateAsync and have the transformFunction look like this:
Edit: UpdateAsync won’t help your issue here, though. The problem is that you’re saving too frequently. Try saving at set intervals (e.g. once a minute) or when a player leaves instead of every time the event fires.
That’s not really how it works. UpdateAsync will first of all, queue everything. UpdateAsync should be used for saving data, in this case, comparing data. It will give you the old data for you to mess with and see what’s inside, then you can use that for saving tecnics. You shouldn’t test things just to use : SetAsync (), UpdateAsync is a Get/Set combo.
how should I do it inside studio, I don’t think it will fire playerremoving in studio? Also, is it possible if I set like 7 datastores (each 6 seconds apart) after the player is removed?
If you set a BindToClose function with a delay it will fire PlayerRemoving in studio. You can also test in a test server and have the player leave before the server disconnects.
It depends on what data you put.
If it is a simple one like boolean, number or short string it will take less than a minute. If it is a large table or a very long string it could take longer.