On-screen interfaces
Create client interfaces and configure layout, text, and buttons.
Screen interfaces contain GUI instances under a player's PlayerGui. Use a
LocalScript for client input and player-specific interface updates.
Create a screen
Parent a ScreenGui to PlayerGui. Set ResetOnSpawn
to false when the screen must persist after respawn.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local screen = Instance.new("ScreenGui")
screen.ResetOnSpawn = false
screen.Parent = player:WaitForChild("PlayerGui")Templates in StarterGui are copied into PlayerGui
on spawn. Change the live PlayerGui to update an existing screen.
Configure size and position
UDim2 combines scale and pixel offset for each axis:
UDim2.new(xScale, xOffset, yScale, yOffset). Scale is relative to the parent;
offset is measured in pixels.
AnchorPoint selects which point within the instance is placed at Position.
(0, 0) is the top-left corner; (0.5, 0.5) is the center. AbsoluteSize and
AbsolutePosition return resolved pixel measurements.
This example requires a ScreenGui named Hud in the local player's PlayerGui.
local gui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
local panel = Instance.new("Frame")
panel.AnchorPoint = Vector2.new(0.5, 0.5)
panel.Size = UDim2.new(0.4, 0, 0, 80)
panel.Position = UDim2.new(0.5, 0, 0.5, 0)
panel.Parent = gui:WaitForChild("Hud")Text and buttons
TextLabel displays text. TextButton adds activation events. Set
BackgroundTransparency to 1 to hide a label's background. Use TextWrapped
for wrapping and text alignment properties for placement within the rectangle.
Connect a button's Activated event for activation. AutoButtonColor controls
automatic pressed-state coloring. PointerEntered and PointerExited report
hover changes.
Send a remote request for actions that change authoritative game state. The server must validate the request.
Arrange children
A UIListLayout arranges children using
LayoutOrder. Its Padding specifies spacing between children.
UIPadding specifies container insets.
World interfaces
BillboardGui displays GUI content facing the camera
at a world instance. Adornee identifies the target and StudsOffset sets a
world offset.
SurfaceGui displays GUI content on a part face.