GuiService
GuiService allows developers to control what GuiObject is currently being selected by the gamepad navigator, as well as check if Roblox's main menu is currently open.
Summary
Properties
If activated, the Select button on a Gamepad or Backslash will automatically set a GUI as the selected object.
Toggles whether or not objects in the CoreGui can be navigated using a Gamepad.
Used to enable and disable the default controller GUI navigation.
Returns true if any menu of CoreGui is open.
Gets the user's preferred transparency as a number between 0 and 1, which indicates how opaque they want the backgrounds of certain UI elements to be. The recommended usage is as a multiplier of an element's BackgroundTransparency. Defaults to 1.
Returns true if the user has enabled reduced motion. Defaults to false.
Sets the GuiObject currently being focused on by the GUI Navigator (used for Gamepads).
Used to determine the absolute size and position of unobstructed area within top bar space.
Used to enable and disable touch controls and touch control display UI. Defaults to true.
Methods
Closes the Inspect Menu, if open.
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.
Allows a developer to bring up the Inspect menu showing the assets listed in this HumanoidDescription object.
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.
Set GuiService.SelectedObject to a child of provided instance selectionParent that is PlayerGui or its descendants.
Opens or closes the player Emotes menu.
Allows developers to disable the built-in notification when a players gameplay is paused.
Allows developers to enable or disable default Inspect and Buy functionality.
Events
Fires when the user closes the Roblox coregui escape menu.
Fires when the user opens the Roblox coregui escape menu.
Properties
AutoSelectGuiEnabled
CoreGuiNavigationEnabled
GuiNavigationEnabled
MenuIsOpen
PreferredTextSize
PreferredTransparency
Code Samples
local DEFAULT_TRANSPARENCY = 0.5
local frame = script.Parent
local function setBackgroundTransparency()
frame.BackgroundTransparency = DEFAULT_TRANSPARENCY * GuiService.PreferredTransparency
end
GuiService:GetPropertyChangedSignal("PreferredTransparency"):Connect(setBackgroundTransparency)
setBackgroundTransparency()
ReducedMotionEnabled
Code Samples
local DEFAULT_TRANSPARENCY = 0.5
local frame = script.Parent
local endPosition = UDim2.fromScale(0.5, 0.8)
if GuiService.ReducedMotionEnabled then
frame.Position = endPosition
else
local moveTweenInfo = TweenInfo.new(0.5)
local moveTweenProps = {
Position = endPosition,
}
local moveTween = TweenService:Create(frame, slideInTweenInfo, slideInTweenProps)
moveTween:Play()
end
SelectedObject
Code Samples
local GuiService = game:GetService("GuiService")
local function printChanged(value)
if value == "SelectedObject" then
print("The SelectedObject changed!")
end
end
GuiService.Changed:Connect(printChanged)
TopbarInset
Code Samples
local GuiService = game:GetService("GuiService")
local Players = game:GetService("Players")
local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true
screenGui.Parent = Players.LocalPlayer.PlayerGui
local frame = Instance.new("Frame")
frame.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
frame.Parent = screenGui
GuiService:GetPropertyChangedSignal("TopbarInset"):Connect(function()
local inset = GuiService.TopbarInset
frame.Size = UDim2.new(0, inset.Width, 0, inset.Height)
frame.Position = UDim2.new(0, inset.Min.X, 0, inset.Min.Y)
end)
TouchControlsEnabled
ViewportDisplaySize
Methods
CloseInspectMenu
Returns
InspectPlayerFromHumanoidDescription
Parameters
Returns
Code Samples
local GuiService = game:GetService("GuiService")
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "3339374070"
humanoidDescription.BackAccessory = "3339363671"
GuiService:InspectPlayerFromHumanoidDescription(humanoidDescription, "MyPlayer")
InspectPlayerFromUserId
Parameters
Returns
Code Samples
local GuiService = game:GetService("GuiService")
GuiService:InspectPlayerFromUserId(772462)
Select
Parameters
Returns
Code Samples
local DEFAULT_TRANSPARENCY = 0.5
local frame = script.Parent
local function setBackgroundTransparency()
frame.BackgroundTransparency = DEFAULT_TRANSPARENCY * GuiService.PreferredTransparency
end
GuiService:GetPropertyChangedSignal("PreferredTransparency"):Connect(setBackgroundTransparency)
setBackgroundTransparency()