Codectionary / Developer documentation / Luau

ScreenGui layers

Place a player interface on the screen and control whether it survives respawn.

Why use ScreenGui?

ScreenGui is a container for on-screen interface objects. Each player receives a copy from StarterGui in PlayerGui; ResetOnSpawn controls what happens to that copy when the character respawns.

Try it in Roblox Studio

Put this LocalScript in StarterPlayerScripts. Start a Studio client and inspect PlayerGui in Explorer; this is a client interface, not server-side UI.

Syntax

screenGui.ResetOnSpawn = false
screenGui.Parent = player.PlayerGui

Examples

ScreenGui layers

Add a persistent HUD container and a small text label.

local Players = game:GetService("Players")
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "PracticeHud"
screenGui.ResetOnSpawn = false
screenGui.Parent = playerGui

local label = Instance.new("TextLabel")
label.Size = UDim2.fromOffset(240, 40)
label.Text = "Practice HUD"
label.Parent = screenGui
  1. PlayerGui is the local player’s interface container; ScreenGui makes its child UI appear on screen.
  2. ResetOnSpawn is inherited from LayerCollector and tells the UI to remain when the character respawns.
  3. The label uses pixel offsets for this small demonstration; production layouts should account for different screen sizes.

Best practices

  • Use StarterGui for authored interfaces and PlayerGui for runtime client instances.
  • Test UI at phone and desktop sizes.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading