So, no errors appear (seems to be a usual with my stuff), and yes, an item is being added to the inventory, but does not run the function. 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

6 comments
Put a print at the start of UpdateOldLabels.
The entire thing works, but only when the player joins, i need it to work when the inventory has an item added to it, you can see it there, but it doesn't work
wait for the backpack in player.
The backpack isn't the inventory, the inventory is a folder inside of the player to hold items
the backpack is definitely the inventory. Yet if you wanted the player to have the item after death you would then place it in the starter backpack
um are you sure? this is my code and I know exactly what it is. the inventory is a totally different thing than the backpack in this case.