For the complete documentation index, see llms.txt. This page is also available as Markdown.

GuiButton

GuiButton : GuiObject

Overview

GuiButton is an abstract class that inherits from GuiObject, defining shared functionality for clickable UI elements like TextButton and ImageButton

Properties

AutoButtonColor

boolean

Specifies whether to automatically darken the background color when the mouse hovers over or presses the button, to indicate the input state.

The default is true. If you want to create the button's color changes directly with a script, setting it to false is recommended.

Code Samples

local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.AutoButtonColor = false

boolean

Specifies whether to display the mouse cursor.

Code Samples

Selected

boolean

Specifies the selection state of the button.

If set to true, the button receives keyboard focus, and if set to false, the focus is released.

Code Samples

Style

Enum.ButtonStyle

Specifies the basic shape to apply to the button.

The default, Custom, uses the button's background properties as they are. Other values apply a predefined corner shape, and values starting with Round display rounded corners.

Code Samples

Methods

Events

Activated

The event triggers when the button is pressed.

It fires when a button is clicked or touched and released over the UI element, executing at the input’s release (Up) rather than its start.

For this event to fire correctly, the button’s Active property must be set to true.

Parameters

InputObject inputObject

The InputObject corresponding to the input that activated the button. nil is passed if the input information cannot be determined.

number clickCount

The number of clicks. Currently, 1 is always passed.

Code Samples

MouseButton1Click

An event that fires when the button is pressed with the left mouse button (or touch) and released over the button.

It fires right before the Activated event. To support multiple input devices together, using the Activated event is recommended.

Parameters

Code Samples

MouseButton1Down

An event that fires the moment the button is pressed with the left mouse button (or touch).

Parameters

number x

The X coordinate (in pixels) on screen where the input occurred.

number y

The Y coordinate (in pixels) on screen where the input occurred.

Code Samples

MouseButton1Up

An event that fires the moment the left mouse button (or touch) that was pressing the button is released.

Parameters

number x

The X coordinate (in pixels) on screen where the input occurred.

number y

The Y coordinate (in pixels) on screen where the input occurred.

Code Samples

MouseButton2Click

An event that fires when the button is pressed with the right mouse button and released over the button.

Parameters

Code Samples

MouseButton2Down

An event that fires the moment the button is pressed with the right mouse button.

Parameters

number x

The X coordinate (in pixels) on screen where the input occurred.

number y

The Y coordinate (in pixels) on screen where the input occurred.

Code Samples

MouseButton2Up

An event that fires the moment the right mouse button that was pressing the button is released.

Parameters

number x

The X coordinate (in pixels) on screen where the input occurred.

number y

The Y coordinate (in pixels) on screen where the input occurred.

Code Samples

SecondaryActivated

An event that fires when a secondary action input on the button is completed.

With a mouse, it fires right after the MouseButton2Click event when the button is pressed and released with the right mouse button.

Parameters

InputObject inputObject

An object containing information about the input that fired the event.

Code Samples

Last updated