Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
GuiObject
Inherits from: GuiBase2d → GuiBase → Instance → Object
GuiObject is an abstract class (much like BasePart) for a 2D user interface object. It defines all the properties relating to the display of a graphical user interface (GUI) object such as Size and Position. It also has some useful read‑only properties like AbsolutePosition, AbsoluteSize, and AbsoluteRotation.
To manipulate the layout of GUI objects in special ways, you can use a layout structure such as list/flex or grid, and you can style them beyond their core properties through appearance modifiers.
Although it's possible to detect mouse button events on any GUI object using InputBegan and InputEnded, only ImageButton and TextButton have convenient dedicated events such as Activated to detect click/press.
Inherits from: GuiBase2d
Descendants: CanvasGroup, Frame, GuiButton, GuiLabel, InputActionLabel, ScrollingFrame, TextBox, TextChannelWindow, VideoDisplay, VideoFrame, ViewportFrame
Memory category: Gui
Tags: NotCreatable, NotBrowsable
Properties
| Name | Type / Returns | Description |
|---|---|---|
| GuiObject.Active | boolean | Determines whether this UI element sinks input. |
| GuiObject.AnchorPoint | Vector2 | Determines the origin point of a GuiObject, relative to its absolute size. |
| GuiObject.AutomaticSize | AutomaticSize | Determines whether resizing occurs based on child content. |
| GuiObject.BackgroundColor | BrickColor | Determines the color of the GuiObject background. |
| GuiObject.BackgroundColor3 | Color3 | Determines the GuiObject background color. |
| GuiObject.BackgroundTransparency | float | Determines the transparency of the GuiObject background and border. |
| GuiObject.BorderColor | BrickColor | Determines the color of the GuiObject border. |
| GuiObject.BorderColor3 | Color3 | Determines the color of the GuiObject border. |
| GuiObject.BorderMode | BorderMode | Determines in what manner the GuiObject border is laid out relative to its dimensions. |
| GuiObject.BorderSizePixel | int | Determines the pixel width of the GuiObject border. |
| GuiObject.ClipsDescendants | boolean | Determines if descendant GuiObjects outside of the bounds of a parent GUI element should render. |
| GuiObject.Draggable | boolean | Determines whether a GuiObject (and its descendants) can be dragged around the screen. |
| GuiObject.GuiState | GuiState | Determines whether the player's mouse is being actively pressed on the GuiObject or not. |
| GuiObject.InputSink | InputSink | Controls whether, and how, the GuiObject sinks input that occurs over it. |
| GuiObject.Interactable | boolean | Determines whether the GuiButton can be interacted with or not, or if the GuiState of the GuiObject is changing or not. |
| GuiObject.LayoutOrder | int | Controls the sort order of the GuiObject when used with a UIGridStyleLayout. |
| GuiObject.NextSelectionDown | GuiObject | Sets the GuiObject which will be selected when the gamepad selector is moved downward. |
| GuiObject.NextSelectionLeft | GuiObject | Sets the GuiObject which will be selected when the gamepad selector is moved to the left. |
| GuiObject.NextSelectionRight | GuiObject | Sets the GuiObject which will be selected when the gamepad selector is moved to the right. |
| GuiObject.NextSelectionUp | GuiObject | Sets the GuiObject which will be selected when the gamepad selector is moved upward. |
| GuiObject.Position | UDim2 | Determines the pixel and scalar position of the GuiObject. |
| GuiObject.Rotation | float | Determines the number of degrees by which the GuiObject is rotated. |
| GuiObject.Selectable | boolean | Determine whether the GuiObject can be selected by a gamepad. |
| GuiObject.SelectionImageObject | GuiObject | Overrides the default selection adornment used for gamepads. |
| GuiObject.SelectionOrder | int | The order of GuiObjects selected by the gamepad UI selection. |
| GuiObject.Size | UDim2 | Determines the pixel and scalar size of the GuiObject. |
| GuiObject.SizeConstraint | SizeConstraint | Sets the Size axes that the GuiObject will be based on, relative to the size of its parent. |
| GuiObject.Transparency | float | A mixed property of BackgroundTransparency and TextTransparency. |
| GuiObject.Visible | boolean | Determines whether the GuiObject and its descendants will be rendered. |
| GuiObject.ZIndex | int | Determines the order in which a GuiObject renders relative to others. |
Inherited from GuiBase2d
| Name | Type / Returns | Description |
|---|---|---|
| GuiBase2d.AbsolutePosition | Vector2 | Describes the actual screen position of a GuiBase2d element, in pixels. |
| GuiBase2d.AbsoluteRotation | float | Describes the actual screen rotation of a GuiBase2d element, in degrees. |
| GuiBase2d.AbsoluteSize | Vector2 | Describes the actual screen size of a GuiBase2d element, in pixels. |
| GuiBase2d.AutoLocalize | boolean | When set to true, localization will be applied to this GuiBase2d and its descendants. |
| GuiBase2d.Localize | boolean | Automatically set to true when a localization table's LocalizationTable.Root targets this object, or an ancestor of this object. |
| GuiBase2d.RootLocalizationTable | LocalizationTable | A reference to a LocalizationTable to be used to apply automated localization to this GuiBase2d and its descendants. |
| GuiBase2d.SelectionBehaviorDown | SelectionBehavior | Customizes gamepad selection behavior in the down direction. |
| GuiBase2d.SelectionBehaviorLeft | SelectionBehavior | Customizes gamepad selection behavior in the left direction. |
| GuiBase2d.SelectionBehaviorRight | SelectionBehavior | Customizes gamepad selection behavior in the right direction. |
| GuiBase2d.SelectionBehaviorUp | SelectionBehavior | Customizes gamepad selection behavior in the up direction. |
| GuiBase2d.SelectionGroup | boolean | Allows customization of gamepad selection movement. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.Archivable | boolean | Determines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published. |
| Instance.archivable | boolean | |
| Instance.Capabilities | SecurityCapabilities | The set of capabilities allowed to be used for scripts inside this container. |
| Instance.IsInSandbox | boolean | Indicates whether the instance is inside a sandboxed container. |
| Instance.Name | string | A non-unique identifier of the Instance. |
| Instance.Parent | Instance | Determines the hierarchical parent of the Instance. |
| Instance.PredictionMode | PredictionMode | Reflects the client-side prediction mode applied to the instance under server-authoritative physics. |
| Instance.RobloxLocked | boolean | A deprecated property that used to protect CoreGui objects. |
| Instance.Sandboxed | boolean | When enabled, the instance can only access abilities in its Capabilities list. |
| Instance.UniqueId | UniqueId | A unique identifier for the instance. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.ClassName | string | A read-only string representing the class this Object belongs to. |
| Object.className | string |
GuiObject.Active
This property determines whether the GuiObject will sink input to 3D space, such as underlying models with a ClickDetector class like DragDetector.
For GuiButton objects (ImageButton and TextButton), this property determines whether Activated fires (AutoButtonColor will still work for those as well). The events InputBegan, InputChanged, and InputEnded work as normal no matter the value of this property.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (TextButton-Active-Debounce).
GuiObject.AnchorPoint
This property determines the origin point of a GuiObject, relative to its absolute size. The origin point determines from where the element is positioned (through GuiObject.Position) and from which the rendered GuiObject.Size expands.
See here for illustrated diagrams and details.
| Field | Value |
|---|---|
| type | Vector2 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (AnchorPoint-Demo).
GuiObject.AutomaticSize
This property is used to automatically size parent UI objects based on the size of its descendants. You can use this property to dynamically add text and other content to a UI object at edit or run time, and the size will adjust to fit that content.
When AutomaticSize is set to an AutomaticSize value to anything other than None, this UI object may resize depending on its child content.
For more information on how to use this property and how it works, please see here.
| Field | Value |
|---|---|
| type | AutomaticSize |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (automaticsize-uilistlayout).
GuiObject.BackgroundColor
Deprecated. This property is deprecated in favor of the Color3 property GuiObject.BackgroundColor3, which should be used in new work instead.
Determines the color of the GuiObject background.
| Field | Value |
|---|---|
| type | BrickColor |
| tags | ["Hidden","NotReplicated","Deprecated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["UI"] |
GuiObject.BackgroundColor3
This property determines the color of a GuiObject background (the fill color). If your element contains text, such as a TextBox, TextButton, or TextLabel, make sure the color of your background contrasts the text's color.
Another property that determines the visual properties of the background is GuiObject.BackgroundTransparency; if this is set to 1, neither the background nor the border will render.
See also BorderColor3.
| Field | Value |
|---|---|
| type | Color3 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Rainbow-Frame).
GuiObject.BackgroundTransparency
This property determines the transparency of the GuiObject background and border. It does not, however, determine the transparency of text if the GUI is a TextBox, TextButton, or TextLabel; text transparency is determined TextBox.TextTransparency, TextButton.TextTransparency, and TextLabel.TextTransparency respectively.
If this property is set to 1, neither the background nor the border will render and the GUI background will be completely transparent.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.BorderColor
Deprecated. This property is deprecated in favor of the Color3 property BorderColor3, which should be used in new work instead.
Determines the color of the GuiObject border.
| Field | Value |
|---|---|
| type | BrickColor |
| tags | ["Hidden","NotReplicated","Deprecated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["UI"] |
GuiObject.BorderColor3
Determines the color of the GuiObject rectangular border (also known as the stroke color). This is separate from the object's GuiObject.BackgroundColor3. You will not be able to see the object's border if its GuiObject.BorderSizePixel property is set to 0.
Note that the UIStroke component allows for more advanced border effects.
| Field | Value |
|---|---|
| type | Color3 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Button-Highlight).
GuiObject.BorderMode
This property determines in what manner the GuiObject border is laid out relative to its dimensions using the enum of the same name, BorderMode.
Note that UIStroke can override this property and allow for more advanced border effects.
| Field | Value |
|---|---|
| type | BorderMode |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.BorderSizePixel
This property determines how wide the GuiObject border renders, in pixels. Setting this to 0 disables the border altogether.
Note that UIStroke can override this property and allow for more advanced border effects.
| Field | Value |
|---|---|
| type | int |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Button-Highlight).
GuiObject.ClipsDescendants
This property determines if the GuiObject will clip (make invisible) any portion of descendant GUI elements that would otherwise render outside the bounds of the rectangle.
Rotation Behavior
When StarterGui.ClipsDescendantsSupportsRotation is enabled, clipping works correctly for rotated shapes. However, clipping by rotated shapes (when the clipping parent itself is rotated) or by rounded corners (UICorner) is not supported.
When StarterGui.ClipsDescendantsSupportsRotation is not enabled and this GuiObject or any ancestor GuiObject has a non‑zero Rotation, this property is ignored and descendant GUI elements will render regardless of this property's value.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.Draggable
Deprecated. This property is deprecated. Use UIDragDetector instead, as it supports more input types and can be better customized.
This indicates whether a GuiObject (and its descendants) can be dragged around the screen.
| Field | Value |
|---|---|
| type | boolean |
| tags | ["Deprecated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Behavior |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.GuiState
When the player's finger is being tapped and held on the GuiObject, the GuiState of the GuiObject will be set to Press. Similarly, When the player's finger is being released from the GuiObject, the GuiState of the GuiObject will be set to Idle, and when Interactable is turned off on the GuiObject, the Class.GuiState of the GuiObject will be set to NonInteractable.
| Field | Value |
|---|---|
| type | GuiState |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | State |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.InputSink
Controls whether, and to what degree, the GuiObject sinks input that occurs over it, using InputSink. Sinking input prevents it from passing through to objects behind the element, including 3D objects in the world such as those with a ClickDetector or DragDetector. It defaults to InputSink.None, except on GuiButton objects (ImageButton and TextButton), where it defaults to InputSink.Activate.
InputSink.None— the object does not sink input on its own.InputSink.Activate— the object sinks the mouse-button and touch press/release input used to activate it, but lets other input (such as mouse movement) pass through.InputSink.All— the object sinks all input that occurs over it.
This property is a more granular successor to the boolean Active property, which can only sink all input or none. The InputBegan, InputChanged, and InputEnded events fire regardless of this property's value.
| Field | Value |
|---|---|
| type | InputSink |
| tags | ["NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":false} |
| capabilities | ["UI"] |
GuiObject.Interactable
Determines whether the GuiButton can be interacted with or not, or if the GuiState of the GuiObject is changing or not.
On a GuiButton:
- When the
Interactablesetting on theGuiButtonis set tofalse, theGuiButtonwill no longer be able to be pressed or clicked, and theGuiStatewill be constantly set toNonInteractable. - When the
Interactablesetting on theGuiButtonis set totrue, theGuiButtonwill behave normally again and theGuiStatewill behave normally.
On a GuiObject:
- When the
Interactablesetting on theGuiButtonis set tofalse, theGuiStatewill be constantly set toNonInteractable. - When the
Interactablesetting on theGuiButtonis set totrue, theGuiStatewill behave normally again.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.LayoutOrder
This property controls the sorting order of the GuiObject when using a UIGridStyleLayout (such as UIListLayout or UIPageLayout) with SortOrder set to SortOrder.LayoutOrder. It has no functionality if the object does not have a sibling UI layout structure.
GuiObjects are sorted in ascending order where lower values take priority over higher values. Objects with equal values fall back to the order they were added in.
If you are unsure if you'll need to add an element between two existing elements in the future, it's a good practice to use multiples of 100 (0, 100, 200, etc.). This ensures a large gap of layout order values which you can use for elements ordered in-between other elements.
See also ZIndex which determines the object's rendering order instead of sorting order.
| Field | Value |
|---|---|
| type | int |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.NextSelectionDown
This property sets the GuiObject selected when the user moves the gamepad selector downward. If this property is empty, moving the gamepad downward will not change the selected GUI.
Moving the gamepad selector downward sets the GuiService.SelectedObject to this object unless the GUI is not Selectable. Note that this property can be set to a GUI element even if it is not Selectable, so you should ensure that the value of a GUI's selectable property matches your expected behavior.
See also NextSelectionUp, NextSelectionLeft, and NextSelectionRight.
| Field | Value |
|---|---|
| type | GuiObject |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Selection |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (creating-a-gamepad-selection-grid).
GuiObject.NextSelectionLeft
This property sets the GuiObject selected when the user moves the gamepad selector to the left. If this property is empty, moving the gamepad to the left will not change the selected GUI.
Moving the gamepad selector to the left sets the GuiService.SelectedObject to this object unless the GUI is not Selectable. Note that this property can be set to a GUI element even if it is not Selectable, so you should ensure that the value of a GUI's selectable property matches your expected behavior.
See also NextSelectionUp, NextSelectionDown, and NextSelectionRight.
| Field | Value |
|---|---|
| type | GuiObject |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Selection |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (creating-a-gamepad-selection-grid).
GuiObject.NextSelectionRight
This property sets the GuiObject selected when the user moves the gamepad selector to the right. If this property is empty, moving the gamepad to the right will not change the selected GUI.
Moving the gamepad selector to the right sets the GuiService.SelectedObject to this object unless the GUI is not Selectable. Note that this property can be set to a GUI element even if it is not Selectable, so you should ensure that the value of a GUI's selectable property matches your expected behavior.
See also NextSelectionUp, NextSelectionDown, and NextSelectionLeft.
| Field | Value |
|---|---|
| type | GuiObject |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Selection |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (creating-a-gamepad-selection-grid).
GuiObject.NextSelectionUp
This property sets the GuiObject selected when the user moves the gamepad selector upward. If this property is empty, moving the gamepad upward will not change the selected GUI.
Moving the gamepad selector upward sets the GuiService.SelectedObject to this object unless the GUI is not Selectable. Note that this property can be set to a GUI element even if it is not Selectable, so you should ensure that the value of a GUI's selectable property matches your expected behavior.
See also NextSelectionDown, NextSelectionLeft, NextSelectionRight.
| Field | Value |
|---|---|
| type | GuiObject |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Selection |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (creating-a-gamepad-selection-grid).
GuiObject.Position
This property determines the GuiObject pixel and scalar position using a UDim2. Position is centered around the object's GuiObject.AnchorPoint.
The scalar position is relative to the size of the parent GUI element, if any.
The pixel portions of the UDim2 value are the same regardless of the parent GUI's size. The values represent the position of the object in pixels. An object's actual pixel position can be read from the GuiBase2d.AbsolutePosition property.
| Field | Value |
|---|---|
| type | UDim2 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.Rotation
This property determines the number of degrees by which the GuiObject is rotated. Rotation is relative to the center of the object, not the AnchorPoint, meaning you cannot change the point of rotation. Additionally, this property is not compatible with ClipsDescendants.
| Field | Value |
|---|---|
| type | float |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.Selectable
This property determines whether the GuiObject can be selected when navigating GUIs using a gamepad.
If this property is true, a GUI can be selected. Selecting a GUI also sets the GuiService.SelectedObject property to that object.
When this is false, the GUI cannot be selected. However, setting this to false when a GUI is selected will not deselect it nor change the value of the GuiService.SelectedObject property.
Add GuiObject.SelectionGained and GuiObject.SelectionLost will not fire for the element. To deselect a GuiObject, you must change the GuiService.SelectedObject property.
This property is useful if a GUI is connected to several GUIs via properties such as this GuiObject.NextSelectionUp, GuiObject.NextSelectionDown, NextSelectionRight, or NextSelectionLeft. Rather than change all of the properties so that the Gamepad cannot select the GUI, you can disable its Selectable property to temporarily prevent it from being selected. Then, when you want the gamepad selector to be able to select the GUI, simply re-enable its selectable property.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Selection |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (limiting-textbox-selection).
GuiObject.SelectionImageObject
This property overrides the default selection adornment used for gamepads.
Note that the chosen SelectionImageObject overlays the selected GuiObject with the Size of the image. For best results, you should size the custom SelectionImageObject via the scale UDim2 values to help ensure that the object scales properly over the selected element.
Changing the SelectionImageObject for a GuiObject element only affects that element. To affect all of a user's GUI elements, set the PlayerGui.SelectionImageObject property.
To determine or set which GUI element is selected by the user, you can use the GuiService.SelectedObject property. The player uses the gamepad to select different GUI elements, invoking the NextSelectionUp, NextSelectionDown, NextSelectionLeft, and NextSelectionRight events.
| Field | Value |
|---|---|
| type | GuiObject |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Appearance |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.SelectionOrder
GuiObjects with a lower SelectionOrder are selected earlier than GuiObjects with a higher SelectionOrder when starting the gamepad selection or calling GuiService:Select() on an ancestor. This property does not affect directional navigation. Default value is 0.
| Field | Value |
|---|---|
| type | int |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Selection |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.Size
This property determines the GuiObject scalar and pixel size using a UDim2.
The scalar size is relative to the size of the parent GUI element, if any.
The pixel portions of the UDim2 value are the same regardless of the parent GUI's size. The values represent the size of the object in pixels. An object's actual pixel size can be read from the GuiBase2d.AbsoluteSize property.
If the GuiObject has a parent, its size along each axis is also influenced by the parent's SizeConstraint.
| Field | Value |
|---|---|
| type | UDim2 |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Health-Bar).
GuiObject.SizeConstraint
This property sets the Size axes that the GuiObject will be based on, relative to the size of its parent.
This property is useful for creating GUI objects that are meant to scale with either the width or height of a parent object, but not both, effectively preserving the aspect ratio of the object.
| Field | Value |
|---|---|
| type | SizeConstraint |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
GuiObject.Transparency
Deprecated. This property is deprecated and indexing it will return BackgroundTransparency.
A mixed property of BackgroundTransparency and TextTransparency.
| Field | Value |
|---|---|
| type | float |
| tags | ["Hidden","NotReplicated","Deprecated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":false} |
| capabilities | ["UI"] |
GuiObject.Visible
This property whether the GuiObject and its descendants will be rendered.
The rendering of individual components of a GuiObject can be controlled individually through transparency properties such as GuiObject.BackgroundTransparency, TextLabel.TextTransparency and ImageLabel.ImageTransparency.
When this property is false, the GuiObject will be ignored by layout structures such as UIListLayout, UIGridLayout, and UITableLayout. In other words, the space that the element would otherwise occupy in the layout is used by other elements instead.
| Field | Value |
|---|---|
| type | boolean |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (UI-Window).
GuiObject.ZIndex
This property determines the order in which a GuiObject renders relative to others.
By default, GuiObjects render in ascending priority order where those with lower ZIndex values are rendered under those with higher values. You can change the render order within a ScreenGui, SurfaceGui, or BillboardGui by changing the value of its ZIndexBehavior.
If you are unsure if you'll need to add an element between two existing elements in the future, it's a good practice to use multiples of 100 (0, 100, 200, etc.). This ensures a large gap of render order values which you can use for elements layered in-between other elements.
See also LayoutOrder which controls the sorting order of a GuiObject when used with a layout structure such as UIListLayout or UIGridLayout.
| Field | Value |
|---|---|
| type | int |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["UI"] |
Methods
| Name | Type / Returns | Description |
|---|---|---|
| GuiObject:TweenPosition | boolean | Smoothly moves a GUI to a new UDim2. |
| GuiObject:TweenSize | boolean | Smoothly resizes a GuiObject to a new UDim2. |
| GuiObject:TweenSizeAndPosition | boolean | Smoothly moves a GUI to a new size and position. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance:AddTag | () | Applies a tag to the instance. |
| Instance:children | Instances | Returns an array of the object's children. |
| Instance:ClearAllChildren | () | This method destroys all of an instance's children. |
| Instance:Clone | Instance | Create a copy of an instance and all its descendants, ignoring instances that are not Archivable. |
| Instance:clone | Instance | |
| Instance:Destroy | () | Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children. |
| Instance:destroy | () | |
| Instance:FindFirstAncestor | Instance? | Returns the first ancestor of the Instance whose Instance.Name is equal to the given name. |
| Instance:FindFirstAncestorOfClass | Instance? | Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className. |
| Instance:FindFirstAncestorWhichIsA | Instance? | Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstChild | Instance? | Returns the first child of the Instance found with the given name. |
| Instance:findFirstChild | Instance | |
| Instance:FindFirstChildOfClass | Instance? | Returns the first child of the Instance whose ClassName is equal to the given class name. |
| Instance:FindFirstChildWhichIsA | Instance? | Returns the first child of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstDescendant | Instance? | Returns the first descendant found with the given Instance.Name. |
| Instance:GetActor | Actor? | Returns the Actor associated with the Instance, if any. |
| Instance:GetAttribute | Variant | Returns the value which has been assigned to the given attribute name. |
| Instance:GetAttributeChangedSignal | RBXScriptSignal | Returns an event that fires when the given attribute changes. |
| Instance:GetAttributes | Dictionary | Returns a dictionary of the instance's attributes. |
| Instance:GetChildren | Instances | Returns an array containing all of the instance's children. |
| Instance:getChildren | Instances | |
| Instance:GetDebugId | string | Returns a coded string of the debug ID used internally by Roblox. |
| Instance:GetDescendants | Instances | Returns an array containing all of the descendants of the instance. |
| Instance:GetFullName | string | Returns a string describing the instance's ancestry. |
| Instance:GetStyled | Variant | Returns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified. |
| Instance:GetStyledPropertyChangedSignal | RBXScriptSignal | Returns an event that fires when the given style property changes on the instance. |
| Instance:GetTags | Array | Gets an array of all tags applied to the instance. |
| Instance:HasTag | boolean | Check whether the instance has a given tag. |
| Instance:IsAncestorOf | boolean | Returns true if an Instance is an ancestor of the given descendant. |
| Instance:IsDescendantOf | boolean | Returns true if an Instance is a descendant of the given ancestor. |
| Instance:isDescendantOf | boolean | |
| Instance:IsPropertyModified | boolean | Returns true if the value stored in the specified property is not equal to the code-instantiated default. |
| Instance:QueryDescendants | Instances | Returns an array containing all descendants of the instance that match the selector string. |
| Instance:Remove | () | Sets the object's Parent to nil, and does the same for all its descendants. |
| Instance:remove | () | |
| Instance:RemoveTag | () | Removes a tag from the instance. |
| Instance:ResetPropertyToDefault | () | Resets a property to its default value. |
| Instance:SetAttribute | () | Sets the attribute with the given name to the given value. |
| Instance:WaitForChild | Instance | Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object:GetPropertyChangedSignal | RBXScriptSignal | Get an event that fires when a given property of the object changes. |
| Object:IsA | boolean | Returns true if an object's class matches or inherits from a given class. |
| Object:isA | boolean |
GuiObject:TweenPosition
Deprecated. This function is deprecated in favor of using TweenService, which allows for better customization using an object-oriented and event-based approach.
- The
easingDirection,easingStyle, andtimeparameters are handled by aTweenInfo - The
overrideparameter is no longer relevant; tweens always override previous tweens on the same property. - The
callbackparameter is better suited by theTween.Completedevent. ThePlaybackStateenum passed by that event provides a more detailed description of the tween's completion state.
Smoothly moves a GUI to a new UDim2 position in the specified time using the specified EasingDirection and EasingStyle.
This function will return whether the tween will play. It will not play if another tween is acting on the GuiObject and the override parameter is false.
See also GuiObject:TweenSize() and GuiObject:TweenSizeAndPosition().
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| endPosition | UDim2 | Where the GUI should move to. | |
| easingDirection | EasingDirection | Out | The direction in which to ease the GUI to the endPosition. |
| easingStyle | EasingStyle | Quad | The style in which to ease the GUI to the endPosition. |
| time | float | 1 | How long, in seconds, the tween should take to complete. |
| override | boolean | false | Whether the tween will override an in-progress tween. |
| callback | Function | nil | A callback function to execute when the tween completes. |
Returns
| Type | Description |
|---|---|
| boolean | Whether the tween will play. |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-TweenPosition1).
GuiObject:TweenSize
Deprecated. This function is deprecated in favor of using TweenService, which allows for better customization using an object-oriented and event-based approach.
- The
easingDirection,easingStyle, andtimeparameters are handled by aTweenInfo - The
overrideparameter is no longer relevant; tweens always override previous tweens on the same property. - The
callbackparameter is better suited by theTween.Completedevent. ThePlaybackStateenum passed by that event provides a more detailed description of the tween's completion state.
Smoothly resizes a GuiObject to a new UDim2 in the specified time using the specified EasingDirection and EasingStyle.
This function will return whether the tween will play. Normally this will always return true, but it will return false if another tween is active and override is set to false.
See also GuiObject:TweenSize() and GuiObject:TweenSizeAndPosition().
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| endSize | UDim2 | The size that the GUI should resize. | |
| easingDirection | EasingDirection | Out | The direction in which to ease the GUI to the endSize. |
| easingStyle | EasingStyle | Quad | The style in which to ease the GUI to the endSize. |
| time | float | 1 | How long, in seconds, the tween should take to complete. |
| override | boolean | false | Whether the tween will override an in-progress tween. |
| callback | Function | nil | A callback function to execute when the tween completes. |
Returns
| Type | Description |
|---|---|
| boolean | Whether the tween will play. |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (tween-a-gui-s-size).
GuiObject:TweenSizeAndPosition
Deprecated. This function is deprecated in favor of using TweenService, which allows for better customization using an object-oriented and event-based approach.
- The
easingDirection,easingStyle, andtimeparameters are handled by aTweenInfo - The
overrideparameter is no longer relevant; tweens always override previous tweens on the same property. - The
callbackparameter is better suited by theTween.Completedevent. ThePlaybackStateenum passed by that event provides a more detailed description of the tween's completion state.
Smoothly resizes and moves a GUI to a new UDim2 size and position in the specified time using the specified EasingDirection and EasingStyle.
This function will return whether the tween will play. Normally this will always return true, but it will return false if another tween is active and override is set to false.
See also GuiObject:TweenSize() and GuiObject:TweenSizeAndPosition().
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| endSize | UDim2 | The size that the GUI should resize. | |
| endPosition | UDim2 | Where the GUI should move to. | |
| easingDirection | EasingDirection | Out | The direction in which to ease the GUI to the endSize and endPosition. |
| easingStyle | EasingStyle | Quad | The style in which to ease the GUI to the endSize and endPosition. |
| time | float | 1 | How long, in seconds, the tween should take to complete. |
| override | boolean | false | Whether the tween will override an in-progress tween. |
| callback | Function | nil | A callback function to execute when the tween completes. |
Returns
| Type | Description |
|---|---|
| boolean | Whether the tween will play. |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| thread safety | Unsafe |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-TweenSizeAndPosition1).
Events
| Name | Type / Returns | Description |
|---|---|---|
| GuiObject.DragBegin | Fired when a player begins dragging the object. | |
| GuiObject.DragStopped | Fired when a player stops dragging the object. | |
| GuiObject.InputBegan | Fired when a user begins interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc). | |
| GuiObject.InputChanged | Fired when a user changes how they're interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc). | |
| GuiObject.InputEnded | Fired when a user stops interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc). | |
| GuiObject.MouseEnter | Fires when a user moves their mouse into a GUI element. | |
| GuiObject.MouseLeave | Fires when a user moves their mouse out of a GUI element. | |
| GuiObject.MouseMoved | Fires whenever a user moves their mouse while it is inside a GUI element. | |
| GuiObject.MouseWheelBackward | Fires when a user scrolls their mouse wheel back when the mouse is over a GUI element. | |
| GuiObject.MouseWheelForward | Fires when a user scrolls their mouse wheel forward when the mouse is over a GUI element. | |
| GuiObject.SelectionGained | Fired when the GuiObject is being focused on with the Gamepad selector. | |
| GuiObject.SelectionLost | Fired when the Gamepad selector stops focusing on the GuiObject. | |
| GuiObject.TouchLongPress | Fires when the player starts, continues and stops long-pressing the UI element. | |
| GuiObject.TouchPan | Fires when the player moves their finger on the UI element. | |
| GuiObject.TouchPinch | Fires when the player performs a pinch or pull gesture using two fingers on the UI element. | |
| GuiObject.TouchRotate | Fires when the player performs a rotation gesture using two fingers on the UI element. | |
| GuiObject.TouchSwipe | Fires when the player performs a swipe gesture on the UI element. | |
| GuiObject.TouchTap | Fires when the player performs a tap gesture on the UI element. |
Inherited from GuiBase2d
| Name | Type / Returns | Description |
|---|---|---|
| GuiBase2d.SelectionChanged | Fires when the gamepad selection moves to, leaves, or changes within the connected GuiBase2d or any descendant GuiObjects. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.AncestryChanged | Fires when the Instance.Parent property of this object or one of its ancestors is changed. | |
| Instance.AttributeChanged | Fires whenever an attribute is changed on the Instance. | |
| Instance.ChildAdded | Fires after an object is parented to this Instance. | |
| Instance.childAdded | ||
| Instance.ChildRemoved | Fires after a child is removed from this Instance. | |
| Instance.DescendantAdded | Fires after a descendant is added to the Instance. | |
| Instance.DescendantRemoving | Fires immediately before a descendant of the Instance is removed. | |
| Instance.Destroying | Fires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy(). | |
| Instance.StyledPropertiesChanged | Fires whenever any style property is changed on the instance, including when a property is set to nil. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.Changed | Fires immediately after a property of the object changes, with some limitations. |
GuiObject.DragBegin
Deprecated. This property is deprecated. Use UIDragDetector instead, as it supports more input types and can be better customized.
This event fires when a player begins dragging the object.
See also GuiObject.DragStopped.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| initialPosition | UDim2 | A UDim2 value of the position of the GuiObject before any drag operation began. |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-DragBegin1).
GuiObject.DragStopped
Deprecated. This property is deprecated. Use UIDragDetector instead, as it supports more input types and can be better customized.
This event fires when a player stops dragging the object.
See also GuiObject.DragBegin.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| x | int | The mouse's X screen location in pixels, relative to the top left corner of the screen. | |
| y | int | The mouse's Y screen location in pixels, relative to the top left corner of the screen. |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-DragStopped1).
GuiObject.InputBegan
This event fires when a user begins interacting with the GuiObject via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc).
The UserInputService has a similarly named event that is not restricted to a specific UI element: UserInputService.InputBegan.
This event will always fire regardless of game state.
See also GuiObject.InputEnded and GuiObject.InputChanged.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| input | InputObject | An InputObject, which contains useful data for querying user input such as the type of input, state of input, and screen coordinates of the input. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (tracking-the-beginning-of-input-on-a-guiobject).
GuiObject.InputChanged
This event fires when a user changes how they're interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc).
The UserInputService has a similarly named event that is not restricted to a specific UI element: UserInputService.InputChanged.
This event will always fire regardless of game state.
See also GuiObject.InputBegan and GuiObject.InputEnded.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| input | InputObject | An InputObject, which contains useful data for querying user input such as the type of input, state of input, and screen coordinates of the input. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (guiobject-inputchanged-demo).
GuiObject.InputEnded
The InputEnded event fires when a user stops interacting via a Human-Computer Interface device (Mouse button down, touch begin, keyboard button down, etc).
The UserInputService has a similarly named event that is not restricted to a specific UI element: UserInputService.InputEnded.
This event will always fire regardless of game state.
See also GuiObject.InputBegan and GuiObject.InputChanged.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| input | InputObject | An InputObject, which contains useful data for querying user input such as the UserInputType, UserInputState, and InputObject.Position. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (tracking-the-end-of-input-on-a-guiobject).
GuiObject.MouseEnter
The MouseEnter event fires when a user moves their mouse into a GuiObject element.
Please do not rely on the x and y arguments passed by this event as a fool-proof way to determine where the user's mouse is when it enters a GUI. These coordinates may vary even when the mouse enters the GUI via the same edge - particularly when the mouse enters the element quickly. This is due to the fact the coordinates indicate the position of the mouse when the event fires rather than the exact moment the mouse enters the GUI.
This event fires even when the GUI element renders beneath another element.
If you would like to track when a user's mouse leaves a GUI element, you can use the GuiObject.MouseLeave event.
See Also
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| x | int | The mouse's X screen coordinate in pixels, relative to the top left corner of the screen. | |
| y | int | The mouse's Y screen coordinate in pixels, relative to the top left corner of the screen. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-MouseEnter1).
GuiObject.MouseLeave
The MouseLeave event fires when a user moves their mouse out of a GuiObject element.
Please do not rely on the x and y arguments passed by this event as a fool-proof way to determine where the user's mouse is when it leaves a GUI. These coordinates may vary even when the mouse leaves the GUI via the same edge - particularly when the mouse leaves the element quickly. This is due to the fact the coordinates indicate the position of the mouse when the event fires rather than the exact moment the mouse leaves the GUI.
This event fires even when the GUI element renders beneath another element.
See Also
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| x | int | The mouse's X screen coordinate in pixels, relative to the top left corner of the screen. | |
| y | int | The mouse's Y screen coordinate in pixels, relative to the top left corner of the screen. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
GuiObject.MouseMoved
Fires whenever a user moves their mouse while it is inside a GuiObject element. It is similar to Mouse.Move, which fires regardless whether the user's mouse is over a GUI element.
Note, this event fires when the mouse's position is updated, therefore it will fire repeatedly while being moved.
The x and y arguments indicate the updated screen coordinates of the user's mouse in pixels. These can be useful to determine the mouse's location on the GUI, screen, and delta since the mouse's previous position if it is being tracked in a global variable.
The code below demonstrates how to determine the Vector2 offset of the user's mouse relative to a GUI element. AbsolutePosition is measured inside the screen's GUI inset, while the x and y arguments of this event are screen coordinates that include it, so the sample calls GetGuiInset() to reconcile the two spaces instead of assuming a fixed inset size.
local Players = game:GetService("Players")
local GuiService = game:GetService("GuiService")
local CustomScrollingFrame = script.Parent
local SubFrame = CustomScrollingFrame:FindFirstChild("SubFrame")
local mouse = Players.LocalPlayer:GetMouse()
local function getPosition(X, Y)
local topLeftInset = GuiService:GetGuiInset()
local gui_X = CustomScrollingFrame.AbsolutePosition.X
local gui_Y = CustomScrollingFrame.AbsolutePosition.Y
local pos = Vector2.new(math.abs(X - gui_X), math.abs(Y - gui_Y - topLeftInset.Y))
print(pos)
end
CustomScrollingFrame.MouseMoved:Connect(getPosition) Note that this event may not fire exactly when the user's mouse enters or exits a GUI element. Therefore, the x and y arguments may not match up perfectly to the coordinates of the GUI's edges.
See Also
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| x | int | The mouse's X screen coordinate in pixels, relative to the top left corner of the screen. | |
| y | int | The mouse's Y screen coordinate in pixels, relative to the top left corner of the screen. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
GuiObject.MouseWheelBackward
The WheelBackward event fires when a user scrolls their mouse wheel back when the mouse is over a GuiObject element. It is similar to Mouse.WheelBackward, which fires regardless whether the user's mouse is over a GUI element.
This event fires merely as an indicator of the wheel's backward movement. This means that the x and y mouse coordinate arguments don't change as a result of this event. These coordinates only change when the mouse moves, which can be tracked by the GuiObject.MouseMoved event.
See Also
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| x | int | The mouse's X screen coordinate in pixels, relative to the top left corner of the screen. | |
| y | int | The mouse's Y screen coordinate in pixels, relative to the top left corner of the screen. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
GuiObject.MouseWheelForward
The WheelForward event fires when a user scrolls their mouse wheel forward when the mouse is over a GuiObject element. It is similar to Mouse.WheelForward, which fires regardless whether the user's mouse is over a GUI element.
This event fires merely as an indicator of the wheel's forward movement. This means that the X and Y mouse coordinate arguments do not change as a result of this event. These coordinates only change when the mouse moves, which can be tracked by the GuiObject.MouseMoved event.
See Also
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| x | int | The mouse's X screen coordinate in pixels, relative to the top left corner of the screen. | |
| y | int | The Y coordinate of the user's mouse. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
GuiObject.SelectionGained
This event fires when the Gamepad selector starts focusing on the GuiObject.
If you want to check from the Gamepad select stops focusing on the GUI element, you can use the GuiObject.SelectionLost event.
When a GUI gains selection focus, the value of the SelectedObject property also changes to the that gains selection. To determine which GUI gained selection, check the value of this property.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-SelectionGained1).
GuiObject.SelectionLost
This event fires when the Gamepad selector stops focusing on the GuiObject.
If you want to check from the Gamepad select starts focusing on the GUI element, you can use the GuiObject.SelectionGained event.
When a GUI loses selection focus, the value of the SelectionObject property changes either to nil or to the GUI element that gains selection focus. To determine which GUI gained selection, or if no GUI is selected, check the value of this property.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (GuiObject-SelectionLost1).
GuiObject.TouchLongPress
This event fires after a brief moment when the player holds their finger on the UI element using a touch-enabled device. It fires with a table of Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires multiple times: UserInputState.Begin after a brief delay, UserInputState.Change if the player moves their finger during the gesture, and finally UserInputState.End. The delay is platform dependent; in Studio it is a little longer than one second.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| touchPositions | Array | An array of Vector2 that describe the relative positions of the fingers involved in the gesture. | |
| state | UserInputState | A UserInputState that describes the state of the gesture: - Begin fires once at the beginning of the gesture (after the brief delay) - Change fires if the player moves their finger while pressing down - End fires once at the end of the gesture when they release their finger. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Move-UI-Element-with-TouchLongPress).
GuiObject.TouchPan
This event fires when the player moves their finger on the UI element using a touch-enabled device. It fires shortly before GuiObject.TouchSwipe would, and does not fire with GuiObject.TouchTap. This event is useful for allowing the player to manipulate the position of UI elements on the screen.
This event fires with a table of Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires multiple times: UserInputState.Begin after a brief delay, UserInputState.Change when the player moves their finger during the gesture, and finally with UserInputState.End.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| touchPositions | Array | A Luau array of Vector2 objects, each indicating the position of all the fingers involved in the gesture. | |
| totalTranslation | Vector2 | Indicates how far the pan gesture has gone from its starting point. | |
| velocity | Vector2 | Indicates how quickly the gesture is being performed in each dimension. | |
| state | UserInputState | Indicates the UserInputState of the gesture. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Panning-UI-Element).
GuiObject.TouchPinch
This event fires when the player uses two fingers to make a pinch or pull gesture on the UI element using a touch-enabled device. A pinch happens when two or more fingers move closer together, and a pull happens when they move apart. This event fires in conjunction with GuiObject.TouchPan. This event is useful for allowing the player to manipulate the scale (size) of UI elements on the screen, and is most often used for zooming features.
This event fires with a table of Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires multiple times: UserInputState.Begin after a brief delay, UserInputState.Change when the player moves a finger during the gesture, and finally with UserInputState.End. It should be noted that the scale should be used multiplicatively.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| touchPositions | Array | A Luau array of Vector2 objects, each indicating the position of all the fingers involved in the pinch gesture. | |
| scale | float | A float that indicates the difference from the beginning of the pinch gesture. | |
| velocity | float | A float indicating how quickly the pinch gesture is happening. | |
| state | UserInputState | Indicates the UserInputState of the gesture. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Pinch-Pull-Scaling).
GuiObject.TouchRotate
This event fires when the player uses two fingers to make a pinch or pull gesture on the UI element using a touch-enabled device. Rotation occurs when the angle of the line between two fingers changes. This event fires in conjunction with GuiObject.TouchPan. This event is useful for allowing the player to manipulate the rotation of UI elements on the screen.
This event fires with a table of Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires multiple times: UserInputState.Begin after a brief delay, UserInputState.Change when the player moves a finger during the gesture, and finally with UserInputState.End.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| touchPositions | Array | A Luau array of Vector2 objects, each indicating the position of all the fingers involved in the gesture. | |
| rotation | float | A float indicating how much the rotation has gone from the start of the gesture. | |
| velocity | float | A float that indicates how quickly the gesture is being performed. | |
| state | UserInputState | Indicates the UserInputState of the gesture. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Touch-Rotation).
GuiObject.TouchSwipe
This event fires when the player performs a swipe gesture on the UI element using a touch-enabled device. It fires with the direction of the gesture (Up, Down, Left or Right) and the number of touch points involved in the gesture. Swipe gestures are often used to change tabs in mobile UIs.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| swipeDirection | SwipeDirection | A SwipeDirection indicating the direction of the swipe gesture (Up, Down, Left or Right). | |
| numberOfTouches | int | The number of touch points involved in the gesture (usually 1). |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Bouncing-Color-Picker).
GuiObject.TouchTap
This event fires when the player performs a tap gesture on the UI element using a touch-enabled device. A tap is a quick single touch without any movement involved (a longer press would fire GuiObject.TouchLongPress, and moving during the touch would fire GuiObject.TouchPan and/or GuiObject.TouchSwipe). It fires with a table of Vector2 objects that describe the relative positions of the fingers involved in the gesture.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| touchPositions | Array | An array of Vector2 that describe the relative positions of the fingers involved in the gesture. |
| Field | Value |
|---|---|
| security | None |
| capabilities | ["UI"] |
Code samples: View on Creator Hub (Tap-Transparency-Toggle).