I have an ImageButton on the screen for muting my game’s music. I initially hooked up the event to ImageButton.Activated, but it clicking on it does not fire the event. Instead, I connected it to ImageButton.MouseButton1Click and it works.
I wanted to use the Activated event because from what I understand, MouseButton1Click is eventually being deprecated. Can anyone else reproduce this behavior of ImageButtons?
local ImageButton = --Put image button here
ImageButton.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
--Do stuff
end
end)
This way is more effective as you can adjust the if statement for multiple input types like this:
ImageButton.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch or Input.UserInputType == Enum.UserInputType.Gamepad1 then
--Do stuff
end
To stop Input (Click, Touch, etc) from reaching beyond the GuiObject and into 3D space. If .Active is false, input will go beyond the GuiObject and into 3D space (to reach things like ClickDetectors)
(For buttons) To toggle on/off the .Activated Event. If .Active is false, .Activated will not fire on click, and vice versa. InputBegan, InputChanged, and InputEnded will all fire normally despite the .Active property.