Help with botched easy tutorial

I have been going through the official roblox scripting courses to learn and/or get a better grip on everything I need to know. Having followed the ‘Interactive Buttons’ tutorial (Interactive Buttons) exactly, as far as I know, my function to print “Button Activated!” is not firing.

The local script is a direct child of the button,
image
and the code is directly copied from the article.

local button = script.Parent

local function onButtonActivated()
	print("Button activated!")

end

button.Activated:Connect(onButtonActivated)

What could the problem be? Or is the tutorial somehow outdated/missing something?

1 Like

try using button.MouseButton1Click instead

1 Like

Activated

Event of:

GuiButton

Description:

Activated fires when the user performs the primary action of the button. Its primary purpose is a cross-platform, general input event for buttons.

  • For pointer-based platforms with a mouse, this fires after the mouse button is pressed then released while hovering over the UI element.
  • For gamepad input, the event fires when the GuiService.SelectedObject is equal to the UI element and the primary gamepad button is pressed then released.
  • For touch input, the event fires when the user touches and releases the UI element.

Although direct input events like GuiObject/MouseButton1Down or GuiObject.InputEnded aren’t deprecated and may still function as you might expect, it is better practice to use this event for general button input instead.

Parameters

Name Type Default Description
inputObject Instance
clickCount int

So basically, if you have a ImageButton, the primary action of a button is to be pressed. So whenever the button is pressed, this should fire. Idk why it isn’t working.

I just made a separate button to test if the script ran fine. It did. I guess I must have changed something within the button that made it unable to activate, so I will look for what it could be.

Alright I figured it out- for some reason I had to uncheck ‘Active’ and then check it again to get it to work. That or I had it clicked off by accident somehow. Thank you for your help!

1 Like