This works, but only once, I need it to work when either of the events are fired, but I've tried multiple ways and none of them work.
Code:
local fram = script.Parent.back
local plr = script.Parent.Parent.Parent
function UpdateOldLabels(Parent)
for i,v in pairs(Parent:GetChildren()) do
if v.Name:sub(1,4):lower() == "item" then
local LineNumber = v.Name:sub(5)
v.Name = "item"..tostring(tonumber(LineNumber) + 1)
v.Position = v.Position + UDim2.new(0.02,0,0,0)
end
end
end
if game.Players.PlayerAdded or plr.Inventory.ChildAdded then
for _,v in pairs(plr:WaitForChild("Inventory"):GetChildren()) do
local item = Instance.new("ImageButton", fram)
item.BackgroundTransparency = 1
item.Name = "item1"
item.Size = UDim2.new(.02, 0, .6, 0)
item.Position = UDim2.new(-.02, 0, 0.15, 0)
item.Image = "rbxassetid://"..tostring(v.itemPrev.Value)
item.ZIndex = 2
UpdateOldLabels(fram)
end
end

2 comments
This is not at all how events work.
the script works perfectly fine,but only works once, and yes events can be used like that