Im having trouble with making an inventory system, it works if i have only singular items, but i want to spice it up and add multiple items in a slot, sorta like minecraft. Anyway the trouble im having is that it wont change the number of the item and will just add another ui item with the updated number
Heres code
for _, block in ipairs(workspace:GetDescendants()) do
if collectionService:HasTag(block, "CanBePickedUp") then
block.ClickDetector.MouseClick:Connect(function(plr)
if #plr.PlayerGui.UI.InventoryUI.InventoryLayout.Inventory:GetChildren() < 15 then
local blockFold = tostring(block)
local plrinv = plr.PlayerGui.UI.InventoryUI.InventoryLayout.Inventory
for _, invitem in ipairs(plr:GetChildren()) do
if block.Name ~= invitem.Name then
task.wait(.1)
block.Parent = plr.Inventory:WaitForChild(blockFold)
local invButton = game.ReplicatedStorage.UI.InventoryButton:Clone()
invButton.Parent = plr.PlayerGui.UI.InventoryUI.InventoryLayout.Inventory
invButton.ObjectName.Text = block.Name
invButton.NumObject.Text = #plr.Inventory:WaitForChild(blockFold):GetChildren()
break
else
if invitem.NumObject then
invitem.NumObject.text = #plr.Inventory:WaitForChild(blockFold):GetChildren()
break
end
end
end
else
print("Inventory full")
end
end)
end
end