I have an inventory gui where the items in the inventory are added as you buy them. This is the script where they get added into the list:
function FillInventoryList()
wait()
InventoryList:ClearAllChildren()
for i,v in pairs(Player.Hats:GetChildren()) do
local List = script.ListItem:clone()
List.Parent = InventoryList
List.Position = UDim2.new(0,0,0,(i-1)*30)
List.Text = v.Name
List.Name = v.Name
end
for i,v in pairs(Player.Faces:GetChildren()) do
local List = script.ListItem:clone()
List.Parent = InventoryList
List.Position = UDim2.new(0,0,0,(i-1+#Player.Hats:GetChildren())*30)
List.Text = v.Name
List.Name = v.Name
end
end
I want to connect something to the list item that I have just added, and I want to do it in the same Local Script. How can I access the item in order to write something like this:
Item.MouseButton1Down:connect(function()
Item.MouseButton1Down:connect(function()
if Player.Hats:WaitForChild("Mesh") and Player.Hats:WaitForChild("Texture") then
game.ReplicatedStorage.Requests.WearItem:FireServer(Player.Hats:WaitForChild("Mesh"), Player.Hats:WaitForChild("Texture"))
end
end)
end)

1 comment
local Item = List.Button? Is the button already created, or do you want to create one?