Reference API Roblox

Engine API

Website

Related

Reference API Roblox

GuiButton

An abstract class for interactive 2D user interface elements.

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is not browsable. It is not visible in Studio's object browser.
Tags: [NotCreatable, NotBrowsable]

Member index 17

HistoryMember
553AutoButtonColor: bool
553Modal: bool
578Selected: bool
553Style: ButtonStyle
483Activated(inputObject: InputObject, clickCount: int)
462MouseButton1Click()
462MouseButton1Down(x: int, y: int)
462MouseButton1Up(x: int, y: int)
462MouseButton2Click()
462MouseButton2Down(x: int, y: int)
462MouseButton2Up(x: int, y: int)
inherited from GuiObject
553Active: bool
553AnchorPoint: Vector2
553AutomaticSize: AutomaticSize
553BackgroundColor3: Color3
553BackgroundTransparency: float
553BorderColor3: Color3
553BorderMode: BorderMode
553BorderSizePixel: int
553ClipsDescendants: bool
553Draggable: bool
588GuiState: GuiState
589Interactable: bool
553LayoutOrder: int
553NextSelectionDown: GuiObject
553NextSelectionLeft: GuiObject
553NextSelectionRight: GuiObject
553NextSelectionUp: GuiObject
553Position: UDim2
553Rotation: float
553Selectable: bool
553SelectionImageObject: GuiObject
553SelectionOrder: int
553Size: UDim2
553SizeConstraint: SizeConstraint
553Visible: bool
553ZIndex: int
462TweenPosition(endPosition: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
462TweenSize(endSize: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
462TweenSizeAndPosition(endSize: UDim2, endPosition: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
462DragBegin(initialPosition: UDim2)
462DragStopped(x: int, y: int)
483InputBegan(input: InputObject)
483InputChanged(input: InputObject)
483InputEnded(input: InputObject)
462MouseEnter(x: int, y: int)
462MouseLeave(x: int, y: int)
462MouseMoved(x: int, y: int)
462MouseWheelBackward(x: int, y: int)
462MouseWheelForward(x: int, y: int)
462SelectionGained()
462SelectionLost()
462TouchLongPress(touchPositions: Array, state: UserInputState)
462TouchPan(touchPositions: Array, totalTranslation: Vector2, velocity: Vector2, state: UserInputState)
462TouchPinch(touchPositions: Array, scale: float, velocity: float, state: UserInputState)
462TouchRotate(touchPositions: Array, rotation: float, velocity: float, state: UserInputState)
462TouchSwipe(swipeDirection: SwipeDirection, numberOfTouches: int)
462TouchTap(touchPositions: Array)
inherited from GuiBase2d
553AbsolutePosition: Vector2
553AbsoluteRotation: float
553AbsoluteSize: Vector2
553AutoLocalize: bool
553RootLocalizationTable: LocalizationTable
553SelectionBehaviorDown: SelectionBehavior
553SelectionBehaviorLeft: SelectionBehavior
553SelectionBehaviorRight: SelectionBehavior
553SelectionBehaviorUp: SelectionBehavior
553SelectionGroup: bool
525SelectionChanged(amISelected: bool, previousSelection: GuiObject, newSelection: GuiObject)
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Removed member index 1

HistoryMember
402SetVerb(verb: string): void

Description

GuiButton is an abstract class that inherits from GuiObject. It is the base class for ImageButton and TextButton. Objects of this type serve to be interactive, clickable user interface elements. It defines several properties for interaction behavior, namely GuiButton.AutoButtonColor and GuiButton.Modal, as well as a handful of events for mouse buttons (GuiButton.MouseButton1Click, GuiButton.MouseButton1Down, etc).

The most important event of a GuiButton is GuiButton.Activated, a multi-platform event that fires when the button is activated. When using a mouse, this means clicking the button and releasing with the cursor still over the UI object. For touch, the same applies but with a touch instead of button press. Finally, for gamepads, GuiButton.Activated fires if a GuiButton is selected when the A-button is pressed and released. In short, this event is very useful for multi-platform user interface programming as it provides a nice general interface for a single user input.

History 43

Members 17

Activated

Parameters (2)
inputObjectInputObject
clickCountint

Fires when the button is activated. As this event doesn't fire on the server, it should only be used in a LocalScript, or in a Script with RunContext of RunContext.Client.

History 4

AutoButtonColor

TypeDefault
bool

The AutoButtonColor determines whether the button automatically changes color when the user's Mouse hovers over or clicks on it.

If true, the button will automatically change color when the mouse hovers over or clicks on it. If false, the button will not change.

If you would like to customize how a button changes when the user's mouse hovers over or clicks on it, consider using an ImageButton GUI and changing the element's ImageButton.HoverImage and ImageButton.PressedImage.

Please note that this property will not have an effect on an ImageButton if it's ImageButton.Image property is set to an image and is not null. Additionally, the property will not affect an ImageButton element on mouse hover when its ImageButton.HoverImage is not null nor on mouse click if ImageButton.PressedImage is not null.

History 4

Modal

TypeDefault
bool

If true while the GUI element is visible, the mouse will not be locked unless the right mouse button is down.

History 4

  • 553 Change Default of Modal from to
  • 486 Change ThreadSafety of Modal from ReadOnly to ReadSafe
  • 462 Change ThreadSafety of Modal from to ReadOnly
  • 47 Add Modal

MouseButton1Click

Parameters (0)
No parameters.

The MouseButton1Click event fires when the user's Mouse fully left clicks the GUI button.

By clicking, the mouse has to be in bounds of the button and has to be pressed down and up again before this event fires. If the mouse leaves the bounds of the button and is released, the event will not fire. If you would like to avoid this limitation, you can use GuiButton.MouseButton1Down and MouseButton1Up. These events are similar, but will fire whenever the user pressed their left mouse down or up, respectively.

This event is similar to GuiButton.MouseButton2Click, which behaves identically except that it is connected to the user's right mouse button.

Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.

History 2

MouseButton1Down

Parameters (2)
xint
yint

The MouseButton1Down event fires when the user presses their left Mouse button down on the GUI object.

This event is similar to GuiButton.MouseButton2Down, which behaves identically except that it is connected to the user's right mouse button.

If you are looking for an event requiring the user to press and release their left mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton1Click.

Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.

History 2

MouseButton1Up

Parameters (2)
xint
yint

The MouseButton1Up event fires when the user releases their left Mouse up off of the GUI object.

This event is similar to GuiButton.MouseButton2Up, which behaves identically except that it is connected to the user's right mouse button.

If you are looking for an event requiring the user to press and release their left mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton1Click.

Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.

History 2

MouseButton2Click

Parameters (0)
No parameters.

The MouseButton2Click event fires when the user's Mouse fully right clicks the GUI button.

By clicking, the mouse has to be in bounds of the button and has to be pressed down and up again before this event fires. If the mouse leaves the bounds of the button and is released, the event will not fire. If you would like to avoid this limitation, you can use GuiButton.MouseButton2Down and MouseButton2Up. These events are similar, but will fire whenever the user pressed their left mouse down or up, respectively.

This event is similar to GuiButton.MouseButton1Click, which behaves identically except that it is connected to the user's left mouse button.

Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.

History 2

MouseButton2Down

Parameters (2)
xint
yint

The MouseButton2Down event fires when the user presses their right Mouse button down on the GUI object.

This event is similar to GuiButton.MouseButton1Down, which behaves identically except that it is connected to the user's left mouse button.

If you are looking for an event requiring the user to press and release their right mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton2Click.

Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.

History 2

MouseButton2Up

Parameters (2)
xint
yint

The MouseButton2Up event fires when the user releases their right Mouse up off of the GUI object.

This event is similar to GuiButton.MouseButton1Up, which behaves identically except that it is connected to the user's left mouse button.

If you are looking for an event requiring the user to press and release their right mouse on a GUI in order for the event to fire, consider using GuiButton.MouseButton2Click.

Note that this event will only fire for GUI buttons, including TextButtons and ImageButton. It will not fire for other GuiObjects.

History 2

Selected

TypeDefault
bool

A boolean property which indicates whether the object has been selected.

History 5

Style

TypeDefault
ButtonStyle

Sets the style of the GuiButton based on a list of pre-determined styles.

History 4

  • 553 Change Default of Style from to
  • 486 Change ThreadSafety of Style from ReadOnly to ReadSafe
  • 462 Change ThreadSafety of Style from to ReadOnly
  • 47 Add Style

Removed members 1

SetVerb

Parameters (1)
verbstring
Returns (1)
void

History 2

Settings