Tools not saving | DataStore Problems

Hello!
So I have this code but for some reason when I rejoin the game, it does not give my tools back.
Did I do anything wrong?

local ToolsData = {}

local function AddToolInTable(tool)
	table.insert(ToolsData, tool)
end

for i, tool in pairs(player.Backpack:GetChildren()) do
	if tool then
		if tool:IsA("Tool") then
			AddToolInTable(tool:Clone())
		end
	end
end

for i, tool in pairs(player.Character:GetChildren()) do
	if tool:IsA("Tool") then
		if tool then
			AddToolInTable(tool:Clone())
		end
	end
end

local Success, ErrorMessage = pcall(function()
	DataStore:SetAsync(player.UserId, Data)
	ToolsDataStore:SetAsync(player.UserId, ToolsData)
end)

You can’t save instances in DataStores, you should instead store their name and give them to players based off the name

For example: loop through the table, check if the tool exists in a folder (the folder contains tools that are given to the players) and give the player tools that were found in the table

1 Like

I’m trying that right now, thanks.

So I made this script.

Basically it stores the name of the tool when the tool is equipped.