Roblox experiences include UI elements that are enabled by default. These include:
- A list of players within the experience.
- The character's health bar.
- The character's backpack.
- A chat window.
- A popup menu of character emotes.
If you don't need any of these elements or if you want to replace the default UI elements with your own creations, StarterGui has the functionality to let you enable or disable each default UI element.
StarterGui has a SetCoreGuiEnabled() function that you can use to disable default UI elements. This function has CoreGuiType enums you can enable or disable when a user enters your experience, including:
To disable individual UI elements, you must specify the CoreGuiType and a boolean value of false for that CoreGuiType. For example, the following LocalScript demonstrates how to disable the health bar while keeping every other default UI element enabled:
local StarterGui = game:GetService("StarterGui")StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
However, if you want to disable all default UI elements except for one, you can also use SetCoreGuiEnabled() to reenable UI elements after you have disabled them. For example, the following LocalScript disables all default UI elements, then reenables the chat window:
local StarterGui = game:GetService("StarterGui")StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
Note that you can only call SetCoreGuiEnabled() in a LocalScript. This means that any changes you make to the default UI elements only apply to the user who owns that LocalScript.
Disabling Touch UI Elements
When users access experiences through a device with touch capabilities, such as a phone or tablet, Roblox adds two additional UI elements to the PlayerGui: a control pad and a jump button. You can hide these two elements by setting the TouchControlsEnabled of the GuiService to a boolean value of false in a LocalScript:
local GuiService = game:GetService("GuiService")GuiService.TouchControlsEnabled = false