I’m making an inventory system and I recently implemented a maximum items per slot. When the amount exceeds this maximum number it should move on to the next slot and create a new stack there but when this happens my GetAttributeChangedSignal() event doesnt trigger. It triggers when it creates an item stack for the first time even tho its the same code.
this is my inventory script:
local fullStack = 5
local function addThingToInventory(Item, plr, addition)
for _, slot in ipairs(plr.PlayerGui.Inventory.Main.InsideFrame.Slots:GetChildren()) do
local item = slot:GetAttribute("Item") or "None"
local amount = slot:GetAttribute("Amount") or 0
if item == "None" then
slot:SetAttribute("Item", Item)
slot:SetAttribute("Amount", addition)
return
elseif item == Item and amount < fullStack then
slot:SetAttribute("Amount", amount + addition)
return
end
end
end
and this is where I detect changes:
slot:GetAttributeChangedSignal("Item"):Connect(function()
print("new item")
local newItem = slot:GetAttribute("Item")
local newId = ItemIds[newItem]
slot.Image.Image = "rbxassetid://"..tostring(newId)
slot.Image.ImageTransparency = 0
end)
slot:GetAttributeChangedSignal("Amount"):Connect(function()
print("new amount")
local newAmount = slot:GetAttribute("Amount")
slot.Amount.Text = newAmount
end)
If anyone knows the problem, please help