I have a GUI with buttons and a function that fires whenever any of the buttons are clicked. However, the function doesn't seem to be returning any data about the actual particular button that was clicked. Is there a way to make this work?
local frame = script.Parent
--script errors at the print function because button never actually exists
function buttonClicked(button)
print(button.Name .. " was clicked!")
end
for i,v in pairs(frame:GetChildren()) do
-- Let's go ahead and check if the object is a button in the first place
if v:IsA("TextButton") or v:IsA("ImageButton") then
-- Connect the event to that individual button.
v.MouseButton1Click:connect(buttonClicked)
end
end

1 comment
your help has been indispensable, thank you!