Module 11 · Roblox UI systems
Frames, labels, and buttons
Create the right UI class, configure it before parenting, and preserve clear roles.
What you will learn
- Choose Frame, TextLabel, or TextButton by purpose
- Configure UI before parenting
- Frame
- A visual UI container.
- TextLabel
- Non-interactive displayed text.
- TextButton
- Text UI intended to activate an action.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
Coin Quest UI stays understandable when containers organize layout, labels present state, and buttons represent actions.
The mental model
Use a Frame to group content, TextLabel to display, and TextButton when the learner can activate a command.
Configure stable names, size, text, and accessibility-relevant behavior before parenting into the visible hierarchy.
New words and symbols
--!strict asks Studio to check your code for type mistakes. It is an instruction for the editor and produces no Output message.
Matching quotes such as "hello" surround a string: a piece of text. The quotation marks tell Luau where the text starts and ends.
local is read as “local”: it creates a name that is available only in the current code scope.
= is read as “is assigned”: it evaluates the right side and stores that value in the name on the left.
. is read as “dot”: it accesses a named property or table field.
A tiny example
--!strictlocal panel = Instance.new("Frame")panel.Name = "CoinPanel"panel.Size = UDim2.fromOffset(240, 80)local label = Instance.new("TextLabel")label.Name = "CoinCount"label.Size = UDim2.fromScale(1, 1)label.Text = "Coins: 0"label.Parent = panelpanel.Parent = script.ParentLine by line
- 3
The Frame is created as a container.
- 5
Its size is stable before display.
- 7
A TextLabel is used because the count is information, not an action.
- 10
The initial text communicates state.
- 11
The configured label enters the panel.
- 13
The complete panel is parented last.
Read the code aloud
Read one statement at a time: name the value being read, what the operation does, and where its result goes. Keep identifiers exactly as written so you can find them again in the code.
Pause at calls, conditions, and loops. Explain when the body runs before moving to the next statement; use the line notes above when a symbol is unfamiliar.
Execution trace
Begin at the first executable statement. Comments and blank lines do not run; a branch chooses which block runs, and a loop may revisit its body.
Line 3: The Frame is created as a container.
Line 5: Its size is stable before display.
Line 7: A TextLabel is used because the count is information, not an action.
Line 10: The initial text communicates state.
Line 11: The configured label enters the panel.
Line 13: The complete panel is parented last.
State before and after
Before running, identify the starting values and any existing Studio objects this example needs. List what you expect to change.
After your practice change, check this result: Each UI Instance class matches its purpose and enters the hierarchy configured.
Reading or printing a value leaves it unchanged. Look for assignments, calls that change state, and property updates to explain each change you observe.
Predict before running
Which class should open a shop when activated?
Try it
Mark each step after you have tried it.
Common mistake
Using a TextLabel as a clickable control hides interaction semantics and lacks a button's Activated event. Choose TextButton for an action.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- Frames group content.
- Labels present information.
- Buttons represent activatable commands.
Next: Next, you will position UI responsively with UDim2 and AnchorPoint.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.