I have a loop that creates multiple TextButtons depending on the players inventory, each TextButton features the same name but with a unique NumberValue instance inside of it to differentiate between.
Currently I'm using this method to detect clicks, but it seems to not be working with the auto generated TextButtons. Do you have any advice how to handle this problem? as I want each button to be clickable.
yScreenMenu.Inventory.ScrollingFrame.TheInventoryItem.MouseButton1Click:connect(function() --Not detecting end)
you can use a for loop
which literates through a table, so you can use :GetChildren()
as it returns a array or well a table and use the variable.
local buttons = script.Parent.Parent:GetChildren() -- define where all the textbuttons are for _,v in pairs(buttons) do -- "v" can be named anything v.MouseButton1Click:Connect(function() --do stuff end) end