GuiService

Show Deprecated
Not Creatable
Service
Not Replicated

The GuiService is a service which currently allows developers to control what GuiObject is currently being selected by the gamepad navigator. It also allows clients to check if Roblox's main menu is currently open.

This service has a lot of hidden members, which are mainly used internally by Roblox's CoreScripts.

Summary

Properties

If activating the Select button on a Gamepad or Backslash will automatically set a GUI as the selected object.

HIDDEN
NOT REPLICATED
HIDDEN
NOT REPLICATED

Toggles whether or not objects in the CoreGui can be navigated using a Gamepad.

HIDDEN
NOT REPLICATED

Used to enable and disable the default controller GUI navigation.

Returns true if any menu of CoreGui is open.

READ ONLY
NOT REPLICATED
HIDDEN
NOT REPLICATED

Sets the GuiObject currently being focused on by the GUI Navigator (used for Gamepads).

Used to enable and disable touch controls and touch control display UI. Defaults to true.

Events

Methods

AddCenterDialog(dialog: Instance, centerDialogType: CenterDialogType, showFunction: function, hideFunction: function): void  


AddKey(key: string): void  


AddSelectionParent(selectionName: string, selectionParent: Instance): void  

Creates a gui selection group where gamepad gui navigation will only consider selectable gui objects that are within the group (children of selectionParent).

AddSelectionTuple(selectionName: string, selections: Tuple): void  

AddSelectionTuple works similarly to GuiService:AddSelectionParent(), but you can give it a tuple of GuiObject that you want to be contained in the group.

Beware that the second argument is not a table, but rather the first of several GuiObject in the tuple. To pass the contents of a table, use unpack/table.unpack:


1local frame = script.Parent
2-- Passing various GuiObject individually
3GuiService:AddSelectionTuple("InventoryButtons", frame.Sort, frame.Trash, frame.Drop)
4-- Unpacking a table of GuiObject (unpack/table.unpack are equivalent)
5local inventoryButtons = { frame.Sort, frame.Trash, frame.Drop }
6GuiService:AddSelectionTuple("InventoryButtons", unpack(inventoryButtons))
7
AddSpecialKey(key: SpecialKey): void  


BroadcastNotification(data: string, notificationType: number): void  


ClearError(): void  


CloseInspectMenu(): void  

Closes the Inspect Menu, if open.

ForceTenFootInterface(isForced: boolean): void  



Checks if the player Emotes menu is open.


Returns whether or not the gameplay paused notification has been disabled by the developer.


Returns two Vector2 values representing the inset of user GUIs in pixels, from the top left corner of the screen and the bottom right corner of the screen respectively.


Returns whether the Inspect and Buy menu functionality is enabled.

InspectPlayerFromHumanoidDescription(humanoidDescription: Instance, name: string): void  

Allows a developer to bring up the Inspect menu showing the assets listed in this HumanoidDescription object.

InspectPlayerFromUserId(userId: number): void  

Allows the Inspect Menu to appear showing the user that has the given UserId.


Returns true if the client is using the ten foot interface, which is a special version of Roblox's UI, exclusive to consoles. This is the only guaranteed way to verify if the user is on a console or not.

RemoveCenterDialog(dialog: Instance): void  


RemoveKey(key: string): void  


RemoveSelectionGroup(selectionName: string): void  

Removes a group that was created with GuiService:AddSelectionParent() or GuiService:AddSelectionTuple().

Select(selectionParent: Instance): void  

Set GuiService.SelectedObject to a child of provided instance selectionParent that is PlayerGui or its descendents.

SetEmotesMenuOpen(isOpen: boolean): void  

Opens or closes the player Emotes menu.


Allows developers to disable the built-in notification when a players gameplay is paused.

SetGlobalGuiInset(x1: number, y1: number, x2: number, y2: number): void  


SetHardwareSafeAreaInsets(left: number, top: number, right: number, bottom: number): void  


SetInspectMenuEnabled(enabled: boolean): void  

Allows developers to enable or disable default Inspect and Buy functionality.

SetMenuIsOpen(open: boolean, menuName: string): void  


SetSafeZoneOffsets(top: number, bottom: number, left: number, right: number): void  


SetUiMessage(msgType: UiMessageType, uiMessage: string): void  

Sets the GuiService's Ui message.

ToggleFullscreen(): void  


Callbacks

Properties

AutoSelectGuiEnabled

If activating the Select button on a Gamepad or Backslash will automatically set a GUI as the selected object. Turning this off will mean that Gui navigation will still work if GuiService.GuiNavigationEnabled is enabled but you will have to set GuiService.SelectedObject manually to start Gui navigation.

CoreEffectFolder

Hidden
Not Replicated

CoreGuiFolder

Hidden
Not Replicated

CoreGuiNavigationEnabled

Hidden
Not Replicated

Toggles whether or not objects in the CoreGui can be navigated using a Gamepad.

GuiNavigationEnabled

Used to enable and disable the default controller GUI navigation.

Read Only
Not Replicated

Returns true if any menu of CoreGui is open.

SelectedCoreObject

Hidden
Not Replicated

SelectedObject

Sets the GuiObject currently being focused on by the GUI Navigator (used for Gamepads). This may reset to nil if the object is off-screen.

This property is changed by the GuiObject.SelectionGained and GuiObject.SelectionLost events.

If you would like to determine when this property changes without tracking the SelectionGained and SelectionLost events for all GUI elements, you can use the Changed event.

TouchControlsEnabled

Used to enable and disable touch controls and touch control display UI. Defaults to true.

Events

CloseInspectMenuRequest

Roblox Script Security

CoreGuiRenderOverflowed

Roblox Script Security

EmotesMenuOpenChanged

Roblox Script Security

Parameters

isOpen: boolean

GuiVisibilityChangedSignal

Roblox Script Security

Parameters

guiType: GuiType
visible: boolean

InspectMenuEnabledChangedSignal

Roblox Script Security

Parameters

enabled: boolean

InspectPlayerFromHumanoidDescriptionRequest

Roblox Script Security

Parameters

humanoidDescription: Instance
name: string

InspectPlayerFromUserIdWithCtxRequest

Roblox Script Security

Parameters

userId: number
ctx: string

KeyPressed

Roblox Script Security

Parameters

key: string
modifiers: string

Fires when the user closes the Roblox coregui escape menu.


Fires when the user opens the Roblox coregui escape menu.


NativeClose

Roblox Script Security

NetworkPausedEnabledChanged

Roblox Script Security

Parameters

enabled: boolean

Open9SliceEditor

Roblox Script Security

Parameters

selectedImageObject: Instance

SafeZoneOffsetsChanged

Roblox Script Security

ShowLeaveConfirmation

Roblox Script Security

SpecialKeyPressed

Roblox Script Security

Parameters

modifiers: string

UiMessageChanged

Roblox Script Security

Parameters

msgType: UiMessageType
newUiMessage: string

Methods

AddCenterDialog

void
Roblox Script Security

Parameters

dialog: Instance
centerDialogType: CenterDialogType
showFunction: function
hideFunction: function

Returns

void

AddKey

void
Roblox Script Security

Parameters

key: string

Returns

void

AddSelectionParent

void

Creates a gui selection group where gamepad gui navigation will only consider selectable gui objects that are within the group (children of selectionParent). A use case is you have a menu pop open, but there are other selectable objects on the screen (maybe from previous menus), but you want to the user to only be able to select gui objects in the new menu.

Parameters

selectionName: string
selectionParent: Instance

Returns

void

AddSelectionTuple

void

Functions similarly to GuiService:AddSelectionParent(), but you can give it a tuple of GuiObject that you want to be contained in the group.

Parameters

selectionName: string

The name of the added selection.

selections: Tuple

The selection(s) added.


Returns

void

No return.

AddSpecialKey

void
Roblox Script Security

Parameters


Returns

void

BroadcastNotification

void
Roblox Script Security

Parameters

data: string
notificationType: number

Returns

void

ClearError

void
Roblox Script Security

Returns

void

CloseInspectMenu

void

This function closes the Inspect Menu, if open, when run from a LocalScript.

See also:


Returns

void

No return.

CloseStatsBasedOnInputString

Roblox Script Security

Parameters

input: string

Returns

ForceTenFootInterface

void
Roblox Script Security

Parameters

isForced: boolean

Returns

void

GetBrickCount

Roblox Script Security

Returns

GetClosestDialogToPosition

Roblox Script Security

Parameters

position: Vector3

Returns

GetEmotesMenuOpen

Returns a boolean indicating whether or not the player Emotes menu is open.

Developers can open or close the Emotes menu by calling the GuiService:SetEmotesMenuOpen() function.


Returns

Indicates whether the Emotes menu is open.

GetErrorCode

Roblox Script Security

GetErrorType

Roblox Script Security

GetGameplayPausedNotificationEnabled

This function returns whether or not the gameplay paused notification has been disabled by the developer.

Developers can enable or disable the notification by calling the GuiService:SetGameplayPausedNotificationEnabled() function.

See also:


Returns

Whether or not the gameplay paused notification has been disabled.

GetGuiInset

Returns two Vector2 values representing the inset of user GUIs in pixels, from the top left corner of the screen and the bottom right corner of the screen respectively.

The inset values supplied by this function only take effect on ScreenGuis that have their IgnoreGuiInset property set to false.


Returns

A tuple of two Vector2 values describing the current specified Gui Inset.

GetGuiIsVisible

Roblox Script Security

Parameters

guiType: GuiType

Returns

GetInspectMenuEnabled

This function returns whether the Inspect and Buy menu functionality is currently enabled. The feature is enabled by default and can be set using the GuiService:SetInspectMenuEnabled() function.

See also:


Returns

A boolean indicating whether the Inspect Menu feature is enabled.

GetNotificationTypeList

Roblox Script Security

Returns

GetResolutionScale

Roblox Script Security

Returns

GetSafeZoneOffsets

Roblox Script Security

Returns

GetUiMessage

Roblox Script Security

Returns

InspectPlayerFromHumanoidDescription

void

This function allows a developer to bring up the Inspect menu showing the assets listed in this HumanoidDescription object.

This allows further customization with what is shown in the Inspect Menu when players inspect other players in your game. If your game modifies what the players are wearing, you can instead give the Inspect Menu a HumanoidDescription object that represents what a player is wearing and those items will be shown. You should pass a name as well to represent the name of the player that will be inspected.

See also:

Parameters

humanoidDescription: Instance

A HumanoidDescription object that contains the assets to show in the Inspect menu.

name: string

The name of the player being Inspected to show in the Inspect menu.


Returns

void

No return.

Code Samples

Opening an Inspect Menu with a HumanoidDescription

1local GuiService = game:GetService("GuiService")
2
3local humanoidDescription = Instance.new("HumanoidDescription")
4humanoidDescription.HatAccessory = "3339374070"
5humanoidDescription.BackAccessory = "3339363671"
6
7GuiService:InspectPlayerFromHumanoidDescription(humanoidDescription, "MyPlayer")

InspectPlayerFromUserId

void

This function allows the Inspect Menu to appear showing the user that has the given UserId. This is especially useful when you want to inspect players who aren't in the current game.

This shows the same information as the "Currently Wearing" tab on the specified user's profile.

See also:

Parameters

userId: number

The UserId of the player to inspect.


Returns

void

No return.

Code Samples

Opening the Inspect Menu for a UserId

1local GuiService = game:GetService("GuiService")
2GuiService:InspectPlayerFromUserId(772462)

InspectPlayerFromUserIdWithCtx

void
Roblox Script Security

Parameters

userId: number
ctx: string

Returns

void

IsMemoryTrackerEnabled

Roblox Script Security

Returns

IsTenFootInterface

Returns true if the client is using the ten foot interface, which is a special version of Roblox's UI, exclusive to consoles. This is the only guaranteed way to verify if the user is on a console or not.


Returns

RemoveCenterDialog

void
Roblox Script Security

Parameters

dialog: Instance

Returns

void

RemoveKey

void
Roblox Script Security

Parameters

key: string

Returns

void

RemoveSelectionGroup

void

Removes a group that was created with GuiService:AddSelectionParent() or GuiService:AddSelectionTuple().

Parameters

selectionName: string

Returns

void

RemoveSpecialKey

void
Roblox Script Security

Parameters


Returns

void

Select

void

When Select is called on an instance selectionParent that is PlayerGui or a descendent of PlayerGui, the engine searches all available selectable, visible and on-screen GuiObjects that are descendents of selectionParent and sets the GuiService.SelectedObject to the GuiObject with the smallest GuiService.SelectionOrder.

Parameters

selectionParent: Instance

The parent of selection whose descendents are searched.


Returns

void

Code Samples

Start Gamepad Selection

1local Players = game:GetService("Players")
2local GuiService = game:GetService("GuiService")
3
4local player = Players.LocalPlayer
5local PlayerGui = player:WaitForChild("PlayerGui")
6
7local screenGui = PlayerGui:WaitForChild("ScreenGui")
8local startSelection = screenGui:WaitForChild("StartSelection")
9
10-- select the best button on the screen when the StartSelection button is activated
11startSelection.Activated:Connect(function()
12 GuiService:Select(PlayerGui)
13end)

SetEmotesMenuOpen

void

Opens or closes the player Emotes menu.

Parameters

isOpen: boolean

Returns

void

SetGameplayPausedNotificationEnabled

void

This method allows developers to disable the built-in notification when a players gameplay is paused. They can then add in their own UI if they wish to customize it.

Developers can query whether the notification is enabled by calling the GuiService:GetGameplayPausedNotificationEnabled() function.

See also:

Parameters

enabled: boolean

Whether or not the built-in notification GUI is disabled.


Returns

void

No return.

SetGlobalGuiInset

void
Roblox Script Security

Parameters

x1: number
y1: number
x2: number
y2: number

Returns

void

SetHardwareSafeAreaInsets

void
Roblox Script Security

Parameters

left: number
top: number
right: number
bottom: number

Returns

void

SetInspectMenuEnabled

void

This function allows developers to enable or disable default Inspect and Buy functionality. This is useful when you want to disable the feature in your game, entirely or during certain parts of your game (such as a cutscene). The feature is enabled by default.

The code sample below demonstrates how to disable the Inspect Menu for your game:


1local GuiService = game:GetService("GuiService")
2GuiService:SetInspectMenuEnabled(false)
3

See also:

Parameters

enabled: boolean

A boolean indicating whether to enable or disable the Inspect Menu feature.


Returns

void

No return.

SetMenuIsOpen

void
Roblox Script Security

Parameters

open: boolean
menuName: string
Default Value: "default"

Returns

void

SetSafeZoneOffsets

void
Roblox Script Security

Parameters

top: number
bottom: number
left: number
right: number

Returns

void

SetUiMessage

void
Local User Security

Sets the GuiService's Ui message.

Parameters

msgType: UiMessageType
uiMessage: string
Default Value: "errorCode"

Returns

void

ShowStatsBasedOnInputString

Roblox Script Security

Parameters

input: string

Returns

ToggleFullscreen

void
Roblox Script Security

Returns

void

ToggleGuiIsVisibleIfAllowed

void
Roblox Script Security

Parameters

guiType: GuiType

Returns

void

GetScreenResolution

Yields
Roblox Script Security

Returns

Callbacks

SendCoreUiNotification

void
Roblox Script Security

Parameters

title: string
text: string

Returns

void