Math and Tables, broken subtraction

Hello,
Im working on inventory data and i ran into problems…
So there is table that holds more tables (or items), each item table has 2 values, Name ([1])
and Count ([2]), Count is number, when i try to do math with it it returns back to its original value (5)

code that controls subtraction:

script.Parent.LocalSEvents.InventoryRemove.Event:Connect(function(itemNum)
	local itemRemoved=inventory[itemNum]
	if itemRemoved~=nil then
	local name=itemRemoved[1]
	local numberLeft=itemRemoved[2]
    if numberLeft > 0 then
		game.ReplicatedStorage.Drop:FireServer(itemRemoved[1])
			numberLeft=numberLeft-1
			print(numberLeft)
	end
	if numberLeft == 0 then
		print("empty")
		script.Parent.LocalSEvents.InventoryFeedBack:Fire(true,itemNum,nil)
		table.remove(inventory,itemNum)
			end

	end
	
end)

Can someone tell me why is this returning Count value?

2 Likes

Problem fixed,

			itemRemoved[2]=itemRemoved[2]-1
2 Likes

Why not use the +=/-=/*=//= assignment instead?

itemRemoved[2] -= 1

never tried before… i will try it but i already made it work…