Lesson 2 of 6
UI design: Figma to Studio, hierarchy, accessibility
Design Roblox game UI in Figma from zero, map frames and auto layout to UDim2 and UIListLayout, and check hierarchy, contrast and accessibility on Beacon Yard's shop.
By the end you can
- Mock up a game screen in Figma with frames, auto layout and a button component, and export an asset for Roblox
- Turn a Figma frame's pixel numbers into UDim2 scale and offset, and auto layout into UIListLayout and UIPadding
- Check a design for hierarchy, contrast, text size and colour-blind safety, and name the Roblox settings that help
- Move hard-coded UI colours into StyleSheet tokens and rules linked to a ScreenGui
Before this: UI fundamentals: ScreenGui, UDim2, layouts
Step 1 of 13
One button that almost fails
Look at the Coin Pack button in Beacon Yard's shop. White text on a gold background, Color3.fromRGB(168, 112, 28). It looks fine on a laptop. Measure it and the white-on-gold pair has a Contrast ratioContrast ratioA number from 1 to 21 that compares how bright two colours are; text needs 4.5 to 1, or 3 to 1 when large.Think of it as how far apart the text and its background look to a tired eye. of about 4.2 to 1. The common accessibility guideline asks for 4.5 to 1 for normal text and 3 to 1 for large text1.

Select a numbered pin, or a row below, to read what it marks.
The same shop as the last lesson, measured. Each pin gives the text contrast of one button.
The buttons use TextSize = 26 with an ExtraBold font, which counts as large text, so the gold button passes. But UiScale can shrink the whole shop to 0.65 on a phone. Then the text is about 17 pixels tall, no longer "large", and the same colours fail. Design decisions and code decisions meet right here.
On a small phone, UiScale sets 0.65 and the Coin Pack text drops to about 17 pixels. What is the cleanest fix?
Press 1 to 4 to choose, Enter to check.
Step 2 of 13
Why design before you build
Building UI in Luau is slow to change. Every colour, gap and font is a property write in a file, and you only see the result after Play. A design tool lets you try ten layouts in the time one takes in code, show them to someone, and only then build the winner. Most studios have a UI designer who works this way and hands the result to a UI scripter.
FigmaFigmaA browser and desktop design tool for screens: frames, auto layout, components and variables.Think of it as a whiteboard where every shape knows how to resize. is the tool most of them use. It runs in a browser or a desktop app, and its free Starter plan includes unlimited drafts, which is enough for this course2. You will need a Figma account; the BuildAlong at the end of this lesson walks through it.
Which of these are faster to try in a design tool than in Studio?
Press 1 to 5 to choose, Enter to check.
Step 3 of 13
Frames and auto layout
In Figma everything sits on a canvas. A frame is a box with a fixed size that holds other layers, like a screen. Make one frame per target screen: 1280 by 720 for a laptop and 844 by 390 for a phone held sideways3.
Auto layout turns a frame into a stack. You choose a direction, the gap between items, the padding at the edges and the alignment, and Figma arranges the children for you. Each child is set to hug contents (its size follows what is inside), fill container (it takes the remaining space) or fixed4. If that sounds familiar, it should: it is the same idea as the shop's UIListLayout and UIPadding.
Go deeper Hug, fill and fixed in Roblox terms
Figma's hug contents is AutomaticSize on a Roblox GUI object: the object grows to fit its children. Fill container is a scale of 1 on that axis, or a UIFlexItem when several children share the leftover space in a UIListLayout. Fixed is an offset-only size. Choosing one per axis in the design tells the scripter exactly which Size to write.
Match each Figma idea to the Roblox piece that does the same job.
Step 4 of 13
Components: design a button once
Draw one shop button: a rectangle with rounded corners and a text layer, inside an auto layout frame. Select it and choose Create component. That is now the main component. Every copy you drag out is an instance that follows the main one, so changing the gold once changes every button5. Variants put several states of a component side by side: Default, Pressed, Disabled.
Name colours too. Figma's variables and styles let you call the gold price/pack instead of #A8701C. Roblox has the same idea now: Design tokenDesign tokenA named value, such as a colour or a size, that many UI pieces share.Think of it as a paint colour with a label on the tin instead of a swatch on the wall.s in a StyleSheet, edited in the Style Editor, so one token changes every button that uses it6.
A button design has a job beyond looking good: it tells the player what happened to their request. Pressing Speed writes a note to the front desk. The server might say yes, or "Not enough coins", or "Already owned". Design a state for each answer, not only for the press.
Think of it as A note to the front-desk clerk
Both sidesRemember: A RemoteEvent is a note to the front-desk clerk.
ShopService can send these Feedback messages for Speed. Which button states does your design need?
Press 1 to 5 to choose, Enter to check.
Step 5 of 13
From pixels in a frame to UDim2
Figma gives you pixels. Roblox wants a scale, an offset or both. The rule: divide the child's size by the frame's size to get a scale, and keep pixels as offset for things that must stay a fixed size, such as a border or a small gap.
Exported art follows the same path. Select a layer, add an export setting such as PNG at 2x, and export7. Upload the PNG as an Image in Studio's Asset Manager and use it on an ImageLabel. For a button background that must stretch without blurring its corners, use 9-slice: ScaleType = Slice with a SliceCenter rectangle8.
The shop panel is 400 by 480 pixels. What AspectRatio (width divided by height) should its UIAspectRatioConstraint use? Two decimals.
Step 6 of 13
Visual hierarchy: what the eye reads first
Hierarchy is the order in which a player's eye reads the screen. Size, colour, contrast and position set it. In the shop the title is largest, the three buy buttons are bright and equal, and Close is grey and last. That says: these three are your choices, and leaving is quiet. Roblox's own design guide gives the same advice: make the important action obvious and keep the rest calm9.
Hierarchy also means the HUD must stay readable while the shop is open, and a player on a phone must reach every button with a thumb. Check your frames at phone size before you call a design done.
Why is the Close button dark grey while the buy buttons are bright?
Press 1 to 4 to choose, Enter to check.
Step 7 of 13
Accessibility: contrast, size, colour and motion
Over 5 percent of people have some form of colour blindness10. In grayscale, Speed, Shield and Coin Pack differ only in their words, which is fine, because each button is labelled. A design that says "press the green one" is not.
Roblox gives players settings your UI should respect. GuiService.PreferredTextSize is the player's text size choice, and it grows text on its own unless you turn on TextScaled. GuiService.ReducedMotionEnabled means the player wants fewer UI animations. GuiService.PreferredTransparency asks for more opaque backgrounds10. Beacon Yard's m07-feel milestone adds its own two settings, ReducedMotion and LargeText, as player attributes that only the server writes. ReducedMotion starts from the player's Roblox Reduce Motion toggle, skips the shop's pop-in tween and thins the particle bursts; LargeText multiplies registered labels by 1.3 on top of Roblox's own text size setting.
A label has TextScaled turned on. A player sets their Roblox text size to large. What happens to that label?
Press 1 to 4 to choose, Enter to check.
Step 8 of 13
Where the front desk breaks
Where does it break?“A note to the front-desk clerk” is a good picture of a remoteevent. Where does it stop being true?
It breaks here. The engine stamps the sender for you, but every other word on the note can be a lie.
The true model. A RemoteEvent carries a one-way message between a client and the server. The server always learns which player sent it; every other argument is untrusted input that the server must check.
A design can promise anything. A Figma prototype can show Speed as bought the instant you click. The game cannot, because the request may be refused or never arrive. Your mockup's "bought" state is a reply from the server, not the result of the click.
Your prototype greys out Speed and shows 0 coins the moment it is clicked. What should the real game do instead?
Press 1 to 4 to choose, Enter to check.
Step 9 of 13
Other tools, and when pros use them
Other ways pros do this
| Option | What it is | When pros pick it | Trade-offs |
|---|---|---|---|
| Figma | Browser and desktop design tool with frames, auto layout, components, variables and Dev Mode. | The default in most studios and most UI job posts; easy to share a link with a scripter. | Proprietary and online; advanced features and team libraries are paid. |
| Penpot | Open-source design tool with flex and grid layouts, components and self-hosting. | You want an open format, no vendor account, or to host it yourself. | Fewer plugins and fewer studios use it, so sharing files with clients is harder. |
| Photopea | Free browser image editor that opens PSD files. | Painting and cutting individual UI images: icons, frames, 9-slice backgrounds. | An image editor, not a layout tool; no auto layout or components. |
| Designing in Studio | Build the UI directly with Studio's UI tools and the Style Editor. | Small games, solo developers, or tuning a design that already exists. | Slow to try alternatives, and the result lives in the place file unless you export it. |
Put a typical UI workflow in order.
- Sketch the screen in Figma frames at phone and desktop size
- Export assets and write down tokens and sizes
- Turn repeated parts into components with their states
- Check contrast, text size and colour-blind safety
- Build it in Studio and test on a real phone
Step 10 of 13
Build along: the shop in Figma
Build along
Create a free Figma account at figma.com, then choose New design file from the home screen.
You should see An empty Figma design file opens with a blank canvas.
Press F for the frame tool, type 1280 and 720 in the size fields in the right panel, and name it Laptop. Make a second frame 844 by 390 named Phone.
You should see Two frames, Laptop 1280×720 and Phone 844×390, sit side by side on the canvas.
Draw a 400 by 480 frame (F) in the Laptop frame, fill it with
#0E1218, and add auto layout (Shift + A) with vertical direction, gap 12 and padding 18. Auto layout belongs to frames, because a plain rectangle cannot hold children. Add a text layer "Quartermaster" and three button frames set to fill container width and 84 tall.You should see A dark panel 400×480 in the middle of the Laptop frame holds a title and three equal buttons spaced 12 apart.
Turn one button into a component (Ctrl + Alt + K on Windows, Cmd + Option + K on Mac), delete the other two and drag in two instances. Override each instance's fill and label.
You should see Changing the main component's colour changes all three buttons at once.
Darken the Coin Pack fill until white text reaches 4.5 to 1, then copy the panel into the Phone frame and scale it to fit the 390 pixel height.
You should see The Coin Pack instance reaches at least 4.5 to 1, checked with a contrast plugin or the Run cell above.
Step 11 of 13
Tokens in Studio: a StyleSheet for the settings panel
Your Figma file now names its colours. The game does not yet. At m14-ship, SettingsGui starts with four colour constants (GOLD, INK, ON, OFF) and sets every colour and corner radius by hand. A StyleSheet moves those values into named tokens that every menu can share6.
- A token is an attribute on a StyleSheet, such as
Gold. A rule uses it as the string"$Gold". - A
StyleRulehas aSelectorand the properties it sets."TextButton"matches a class,".SettingOn"a tag,"#Panel"a name, and"#Panel > UIStroke"a direct child11. - A
StyleLinkinside a ScreenGui applies one sheet to everything in it. AStyleDerivelets a design sheet borrow the tokens of another.
The Style Editor on Studio's UI tab builds the same instances without code12. Here they come from code, so they live in Git:
-- src/client/YardStyle.luau
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local YardStyle = {}
local function rule(sheet: StyleSheet, selector: string, properties: { [string]: string })
local made = Instance.new("StyleRule")
made.Selector = selector
made:SetProperties(properties)
made.Parent = sheet
end
function YardStyle.link(screen: ScreenGui)
local tokens = Instance.new("StyleSheet")
tokens.Name = "YardTokens"
tokens:SetAttribute("Ink", Color3.fromRGB(245, 247, 250))
tokens:SetAttribute("Gold", Color3.fromRGB(232, 184, 74))
tokens:SetAttribute("Night", Color3.fromRGB(14, 18, 24))
tokens:SetAttribute("On", Color3.fromRGB(28, 122, 78))
tokens:SetAttribute("Off", Color3.fromRGB(48, 52, 60))
tokens:SetAttribute("Radius", UDim.new(0, 8))
tokens:SetAttribute("PanelRadius", UDim.new(0, 10))
tokens.Parent = ReplicatedStorage
local design = Instance.new("StyleSheet")
design.Name = "YardDesign"
local derive = Instance.new("StyleDerive")
derive.StyleSheet = tokens
derive.Parent = design
design.Parent = ReplicatedStorage
rule(design, "#Panel", { BackgroundColor3 = "$Night" })
rule(design, "#Panel > UIStroke", { Color = "$Gold" })
rule(design, "TextButton > UICorner", { CornerRadius = "$Radius" })
rule(design, "#Panel > UICorner", { CornerRadius = "$PanelRadius" })
rule(design, "TextLabel, TextButton", { TextColor3 = "$Ink" })
rule(design, ".SettingOn", { BackgroundColor3 = "$On" })
rule(design, ".SettingOff", { BackgroundColor3 = "$Off" })
local link = Instance.new("StyleLink")
link.StyleSheet = design
link.Parent = screen
end
return YardStyle
Build along
src/client/YardStyle.luausrc/client/SettingsGui.luau
Add
YardStyle.luauand callYardStyle.link(screen)inSettingsGui.startright after the ScreenGui is made. Delete the lines that setpanel.BackgroundColor3,stroke.Color,title.TextColor3,button.TextColor3anduiCorner.CornerRadius.You should see Opening Settings with P shows the same dark panel, gold outline and white text as before, and the Properties window flags those properties with a warning sign; hovering one names the style.
In
render, replace theBackgroundColor3line with tags: addSettingOnand removeSettingOffwhen the setting is on, and the reverse when it is off.You should see Toggling a setting turns its button green and back to grey, with no colour set in SettingsGui.
Change the
Goldvalue inYardStyle.luauto another colour, let Rojo sync, and press Play again.You should see After one edit to the Gold token, the settings panel outline shows the new colour, and nothing else in SettingsGui changed.
You link YardDesign but forget to delete one line in SettingsGui. Then you change the Ink token to black. What colour is that button's text?
button.TextColor3 = INK -- still in toggle()
Press 1 to 4 to choose, Enter to check.
Step 12 of 13
Challenges
Level 1, Apprentice
Challenge
Turn the shop's colours into named design tokens in Figma, and build a matching light-theme test of the shop panel.
- Start from
- The game at milestone m06 (download)
Done means
- Local Figma color variables (or color styles) named by role for each shop colour (such as surface/panel, price/speed, price/shield, price/pack)
- Every button instance uses a named variable, not a raw hex value
- A second light-theme copy of the shop frame uses a matching light colour set (or a second variable mode if you are on Figma's Education or paid plan)
Meet the criteria above, then record your own result. No test grades this check.
Level 3, Professional
Challenge
Write the three functions in challenges/work/ui_design.luau in the game repo (start from the m14-ship tag to get challenges/work/ui_design.luau and challenges/ui-design.luau). The test checks them against the shop's real colours, including the Coin Pack at UIScale 0.65. The written solution is challenges/solutions/ui-design.md.
- Start from
- The game at milestone m14 (download)
- Grade it
- In Studio, press Play, then run
game.ServerScriptService.RunGameTests:Invoke("ui-design", "ui-design-contrast")in the server command bar. Copy the pass code from Output.
Done means
- challenges/work/ui_design.luau exports contrastRatio(a, b), toScale(px, framePx) and passes(ratio, textPx, bold)
- contrastRatio computes the WCAG contrast ratio of two RGB colours
- toScale converts a Figma pixel size to a UDim2 scale rounded to 3 decimal places (math.round(px / framePx * 1000) / 1000)
- passes returns whether a contrast ratio meets WCAG AA for the given text pixel size and bold flag
- challenges/ui-design.luau prints TEST PASS for every check
A bold label is 26 pixels tall at UIScale 1. Below what UIScale does it stop counting as large bold text (18.66 pixels)? Two decimals.
Step 13 of 13
Recap
Recap
- Design in Figma first: frames per screen size, auto layout for stacks, components with every state the server can answer with.
- Auto layout maps to UIListLayout and UIPadding; pixel sizes become a scale by dividing by the frame, plus an aspect ratio constraint.
- Check contrast at the smallest UIScale your game uses: the gold Coin Pack passes as large text at 26 pixels and fails at 0.65.
- In Studio, tokens are StyleSheet attributes used as $Name in StyleRules, a StyleLink applies the sheet to a ScreenGui, and a value set on the instance overrides the style.
A RemoteEvent is a note to the front-desk clerk, until the engine stamps the sender for you, but every other word on the note can be a lie.
Queued for review