"Activated" event does not seem to fire for ImageButtons

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?

Is the Active property set to true? How about the Selectable property?

2 Likes

I set “Active” to true and it works.

Edit: I don’t understand what “Active” is very well from the wiki article for it though.

You can do it like this:

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

end)

.Active serves two purposes:

  1. 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)
  2. (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.
2 Likes