I have a hundred MouseButton1Down
events and I need to obtain the original TextButton object that triggered the event, inside each function.
Currently, I have to manually declare the object name one by one inside the print
:
TextButton1.MouseButton1Down:Connect(function() print(TextButton1) end)
TextButton2.MouseButton1Down:Connect(function() print(TextButton2) end)
TextButton3.MouseButton1Down:Connect(function() print(TextButton3) end)
I wonder if there is any automatic way to get this GUI object that fired the event, something like self
(although self
doesn’t work in this case):
TextButton1.MouseButton1Down:Connect(function() print(self) end) -- should print 'TextButton1'
TextButton2.MouseButton1Down:Connect(function() print(self) end) -- should print 'TextButton2'
TextButton3.MouseButton1Down:Connect(function() print(self) end) -- should print 'TextButton3'