I have a GUI and I'm trying to detect if ANY buttons within a table have been clicked, and then fire a function based on that. Is this the right way to go about it? (I feel like it isn't). Thanks for your help in advance!
frame = script.Parent
buttons = {}
-- create buttons table
for _,v in pairs (frame:getChildren()) do
if v:IsA("ImageButton") then
table.insert(buttons, v)
end
end
function buttonClicked(button)
end
--when any button is clicked
buttons.Mouse1ButtonClick:connect(buttonClicked())

5 comments
Hate to bug you again, but am I able to connect the function with the particular BUTTON that was clicked? I want to get data about the particular button whenever the function fires
You mean have the function that executes once the event is fired, be somewhere else in the script?
I mean I'd like to be able to use the exact button that was clicked as a variable inside of the function.
No problem, answered it in your latest question.
Yep! Thanks