How could i do this

How would i make it so that if there is two of the same things in an inventory then the textlabel that i have in the textbutton would say how much of the same things there are?

Remotes.AddToInventory.OnClientEvent:Connect(function(name, info)
	local haha = {name, info}
	table.insert(InventoryTable.Inventory, haha)
end)

InventoryButton.MouseButton1Click:Connect(function()
	InventoryFrame.Visible = not InventoryFrame.Visible
	if InventoryFrame.Visible == true then
		for i,v in InventoryFrame:GetChildren() do
			if v:IsA("TextButton") then
				v:Destroy()
			end
		end
		local items = {}
		for i,v in InventoryTable.Inventory do
			local TextButton = script.TextButton:Clone()
			TextButton.Parent = InventoryFrame
			TextButton.Name = v[1]
			TextButton.Text = v[1]
		end
		end

end)

1 Like

Just loop through all the children of the inventory and put the names into a dictionary. You can do something like

items[tool.Name] = (items[tool.Name] or 0) + 1

After that you just create text labels through looping that dictionary. Another way you can do it is just to create the text labels every time you encounter a new item.