So, I've tried multiple ways of doing this, but it normally just overlaps or duplicates the previous items, so how can I run this when a player either joins, or gains an item (plr:WaitForChild("Inventory").ChildAdded)
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
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

1 comment
nope, you are missing the connect part. Specificly in roblox, a connect to an event is required to handle the event. the connect function requires a function as parameter, so an example is game.Players.PlayerAdded:connect()