UI
Client service for on-screen messages, windows and panels, and access to StarterGui widgets.
local UI = game:GetService("UI")Windows and panels are containers for widgets.
Methods
ShowMessage
UI:ShowMessage(text: string, seconds: number?)Displays text near the top of the local player's screen for seconds (default 4). Pass 0 to keep it until cleared. For a message shown to every player, call game:Message on the server.
ClearMessage
UI:ClearMessage()Clears the message set by ShowMessage.
FindFirstChild
UI:FindFirstChild(name: string): Widget?Returns the StarterGui widget with the given name, or nil.
local button = UI:FindFirstChild("PlayButton")
button.Pressed:Connect(function()
button.Text = "Loading..."
end)CreateWindow
UI:CreateWindow(width: number, height: number, style: string?): WidgetCreates a translucent window docked to the left edge. With style set to "toolbar" it docks to the bottom edge.
local window = UI:CreateWindow(260, 180)
window:AddLabel("Shop", 18, true)CreatePanel
UI:CreatePanel(options: table): WidgetCreates a freely positioned panel. X, Y, AnchorX and AnchorY are normalized screen coordinates from 0 to 1.
| Option | Default | Description |
|---|---|---|
X, Y | 0.5, 0.02 | Normalized screen position. |
AnchorX, AnchorY | 0.5, 0 | Normalized anchor point within the panel. |
Width, Height | 400, 140 | Size in pixels. |
Padding | 10 | Inner padding in pixels. |
local panel = UI:CreatePanel({ Y = 0.05, Width = 300, Height = 60 })
panel:AddLabel("Round 1", 20, true)Remember
UI:Remember(name: string, text: string)Persists a string on the local device, scoped to this game. Not visible to the server or other devices. Use DataStore for authoritative data.
Recall
UI:Recall(name: string): string?Returns the string stored with Remember, or nil.