Its possible reduce a number in a table?

Hello, can anyone help me?
Is it possible to reduce the table number later in the same script? I need to reduce
Count

local Players  = game:GetService("Players")
local player   = Players.LocalPlayer
local backpack = player.Backpack
local char     = player.Character or player.CharacterAdded:Wait()

local function ScanItems()
local items = {}

--Scanning Backpack
for i, tool in pairs(backpack:GetChildren()) do
	if tool.ClassName == "Tool" then
		table.insert(items, tool)
	end
end

--Scanning Character
for i, tool in pairs(char:GetChildren()) do
	if tool.ClassName == "Tool" then
		table.insert(items, tool)
	end
end

--Creating New List
local invItems = {}

for i, tool in pairs(items) do
	if invItems[tool.Name] then
		invItems[tool.Name].Count += 1
		table.insert(invItems[tool.Name].Items, tool)
	else
		invItems[tool.Name] = 
			{Count = 1;
			Items = {tool};
			}
	end
end
return invItems
end

You mean like invItems[tool.Name].Count -= 1?

Exactly it just isn’t working

invItems[tool.Name].Count -= 1

It’s correct, right? So I’ll have to look for another error in my script, thanks for your attention

1 Like