I am having the above error when trying to save player's clothes. When you click on the surfaceGUI "Buy Clothes" (TextButton), this script gets run:
local ds = game:GetService("DataStoreService"):GetDataStore("ClothesStore1")
game.Players.PlayerAdded:Connect(function(player)
local key = "clothes-"..player.UserId
local folder = Instance.new("Folder")
folder.Name = "Clothes"
folder.Parent = player
local current = Instance.new("StringValue")
current.Name = "CurrentClothes"
current.Parent = folder
local shirt = Instance.new("StringValue")
shirt.Name = "Shirt"
shirt.Parent = current
local pants = Instance.new("StringValue")
pants.Name = "Pants"
pants.Parent = current
local save = ds:GetAsync(key)
if save then
for i = 1, #save do
if game.ServerStorage.Clothes:FindFirstChild(i) then
local clone = game.ServerStorage.Clothes:FindFirstChild(save[i]):Clone()
clone.Parent = folder
end
end
end
player.CharacterAdded:Connect(function(character)
if shirt.Value ~= "" then
character:WaitForChild("Shirt").ShirtTemplate = shirt.Value
character:WaitForChild("Pants").PantsTemplate = pants.Value
end
end)
end)
game.ReplicatedStorage.BuyClothes.OnServerEvent:Connect(function(player, shirt, pants, cName)
local key = "clothes-"..player.UserId
player.Character.Shirt.ShirtTemplate = shirt
player.Character.Pants.PantsTemplate = pants
player.Clothes.CurrentClothes.Value = cName
player.Clothes.CurrentClothes.Shirt.Value = shirt
player.Clothes.CurrentClothes.Pants.Value = pants
local clothes = game.ServerStorage.Clothes:FindFirstChild(cName):Clone()
clothes.Parent = player.Clothes
local saved = {}
for i,v in pairs(player.Clothes:GetChildren()) do
if v.Name == "CurrentClothes" then
table.insert(saved, v.Name)
ds:SetAsync(key, saved)
end
end
end)
What is this script supposed to do?
Well, this script saves the players clothes which he bought and then when the player re-joins the game, the clothes should be saved.
So what is the problem?
Whenever the player leaves the game, the output shows this message "DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = clothes-443643048"
And then it does not save the clothes.
I think that this problem is because of the queue of the keys is filled.
How do I resolve this issue?
Thanks

2 comments
save datastores less lmao
You are putting
SetAsyncinto a loop, so it calls the function multiple times, first, put all values into the table, and then outside the loop save the table.