Data Store 'unknown error'

I made a data store system for a crate system in my game, and everything has been fine. However, recently I’ve been getting errors, even though I haven’t touched the script at all and everything looks fine.

I either get one of these two errors:


When I get the first error, my data still saves. However, when I get the second error my data doesn’t save.

Here is the bugged part:

        local inventory = {}
		for _, item in pairs(plr:WaitForChild("Emotes"):GetChildren()) do
			table.insert(inventory, item.Name)
		end
		if playersUnboxing[plr] then
			table.insert(inventory, playersUnboxing[plr])
		end

		local compiledData = {
			Inventory = inventory;
			Equipped = plr.EmoteEquipped.Value
		}

		local success, err = nil, nil
		while not success do
			success, err = pcall(function()
				ds:SetAsync(plr.UserId, compiledData)
			end)

			if err then
				warn("Data Store |",err)
			elseif success then
				print("Data Store | Emote data saved for "..plr.Name)
			end
			task.wait(.5)
		end

If you have any tips that would be greatly appreciated!

1 Like

I would suggest increasing the task.wait time.
Datastore requests are rate limited and firing too many to the same key too frequently will give you the first warning.

The error looks like it was caused by the number of requests exceeding the limit, so it’s dropped the additional requests.

I would think about adding an attempt limit and a back off.

--for example
local attempt = 1
local waiting = 1
repeat
--code to save
task.wait(waiting)
waiting += 2
attempt+= 1
until success or attempt== 5
if success then
--do stuff
else
--warn data failed to save
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.