Hello, im trying to implement a stack size to my items so the user has to have inventory management. My current way doesn’t work as I wanted as it only stacks once and then adds items separately to a different slot but the image doesn’t show up.
current code:
local function AddItem(UI, item, amt)
local itemType = ItemModule[item.Name]["Type"]
for counter = 1,invsize do
local slot = UI:WaitForChild("Slot"..counter)
local itemAmt = GetItemAmt(playerInventory[itemType], slot)
if not playerInventory[itemType]["Slot"..counter] then continue end
if not (GetItemAmt(playerInventory[itemType], slot) > ItemModule[item.Name]["StackSize"]) == false then continue end
if playerInventory[itemType]["Slot"..counter][item.Name] == GetItemAmt(playerInventory[itemType], slot) then --doesn't work
print("adding item")
slot.Icon.Image = ItemModule[item.Name]["Image"]
if itemAmt == 1 then
slot.Amount.Text = ""
else
slot.Amount.Text = itemAmt
end
itemClicked(slot)
break
end
end
end
Can anyone help?