DataStore request was added to queue (lost all tool data)

DataStore request was added to queue. (lost all tool data)

local ToolFolder = game:GetService("ServerStorage"):FindFirstChild("SavedTools")
local DataStoreService = game:GetService("DataStoreService")
local SaveData = DataStoreService:GetDataStore("SieDffsagtfa32")

game.Players.PlayerAdded:Connect(function(Player)
	local ToolData = SaveData:GetAsync(Player.UserId)
	
	local BackPack = Player:WaitForChild("Backpack")
	local StarterGear = Player:WaitForChild("StarterGear")
	
	if ToolData ~= nil then
		for i, v in pairs(ToolData) do
			if ToolFolder:FindFirstChild(v) and BackPack:FindFirstChild(v) == nil and StarterGear:FindFirstChild(v) == nil then
				ToolFolder[v]:Clone().Parent = BackPack
				ToolFolder[v]:Clone().Parent = StarterGear
			end
		end
	end

	Player.CharacterRemoving:Connect(function(Character)
		Character:WaitForChild("Humanoid"):UnequipTools()
	end)
end)

game.Players.PlayerRemoving:Connect(function(Player)
	local ToolTable = {}
	
	for i, v in pairs(Player.Backpack:GetChildren()) do
		table.insert(ToolTable, v.Name)
	end
	if ToolTable ~= nil then
		SaveData:SetAsync(Player.UserId, ToolTable)

	end
end)

You can only send a datastore request every 6 seconds, I would recommend using this to prevent data corruption.

1 Like

sry im not sure i understood what to do

Use the module’s apis instead of the normal data store apis in order to save data.

can you explain in other in ways, I still cant understand you.
(show example?)

If you are experiencing data loss in your game then I would recommend learning about profile service, a library for interacting with data-stores that is made by another player.

Firstly go to the devforum post Save your player data with ProfileService! (DataStore Module) and then follow instructions on there.

There is additionally an example on there.

Im just doing datastore with tool folder in storage I dont really understand this thing maybe you can just fix my script?

I looked at your script, I can’t see anything wrong. The only reason you would be getting this error is because you are reading / writing data too fast, that’s why I recommended the profile service. If you don’t understand the profile service then there are tutorials on youtube that could help you with it.

you can send me one?
max charrrrr

I just remind you i need for tool not leaderstats

True, but this works for any data.

Additionally I would recommend storing tools in a permanent table.

1 Like

k i will check it later
max charrr

I wouldn’t recommend this. Learning datastore by yourself is the best option so you will know what causes every errors and data loss.