Lesson 3 of 6

Console, VR and the 10-foot screen

Get a Roblox game ready for Xbox, PlayStation and VR: 10-foot text, the TV-safe area, gamepad menus with no dead ends, Controller Emulator, console release rules and a VR comfort check on Beacon Yard.

Lab lesson, about 60 minutes, 11 steps

By the end you can

  • Size Beacon Yard's text and margins for a TV about 3 metres away, using GuiService.ViewportDisplaySize and the TV-safe area
  • Find and fix gamepad dead ends with selection groups and a Back button, and test them in Controller Emulator
  • Name what a console release needs: content ratings, no chat window, the console device setting
  • Run a short VR check and switch off what makes a headset uncomfortable

Before this: UI design: Figma to Studio, hierarchy, accessibility, Input everywhere, part 1: keyboard, gamepad, touch and accessibility

1Three metres from the TV

Open the finished game at m14-ship and look at how Beacon Yard sizes its interface. Every screen calls one helper:

		local shorter = math.min(size.X, size.Y)
		uiScale.Scale = math.clamp(shorter / 720, 0.65, 1.4)
Figure 1.1

It reads the shorter side of the viewport in pixels and divides by 720. That was the right fix for phones in UI fundamentals: ScreenGui, UDim2, layouts. Now think about two players. One has a 15.6 inch laptop, 60 cm from their eyes. The other has a 55 inch TV, 3 metres from the sofa. Both screens are 1080 pixels tall.

Console players sit 8 to 10 feet (2.4 to 3 metres) from the screen, and Roblox's console guidelines ask you to build for that ten-foot experienceTen-foot UIAn interface built to be read and used from a sofa, about 3 metres from a TV, with a gamepad.Think of it as the menu board on the wall of a café, not the menu in your hand.1.

UiScale.luau runs on the laptop (1920 by 1080) and on the TV (1920 by 1080). What does this print?

local function scale(x, y)
	return math.clamp(math.min(x, y) / 720, 0.65, 1.4)
end
print(scale(1920, 1080), scale(1920, 1080))
  1. 1.4 1.4
  2. 1.5 1.5
  3. 1.4 2.1
  4. 1 1.4
Answer

1.4 1.4. Pixels alone cannot tell a laptop from a TV. Both get UiScale 1.4, so the TV shows the same pixel sizes to a player five times further away.

Open this step in lesson mode · Link to this step · This confused me

2How big text looks from the sofa

What your eye sees is the angle a letter covers. A pixel on the 55 inch TV is bigger than a pixel on the laptop, but the TV is five times further away. Divide the height of one pixel by the distance and you can compare any two screens.

Client sideA ten-foot console screen is the menu board on the wall across a café, instead of the menu in your hand.
In the pictureIn Roblox
Reading the board from the back of the caféReading the TV from a sofa about 3 metres away, so the same pixels look smaller
Bigger letters on the boardLarger text when GuiService.ViewportDisplaySize is Large, such as Beacon Yard's Larger text setting
A pillar that hides the edge of the boardA TV that crops the outer edges of the picture, so essential UI stays in the TV-safe area

See the whole analogy cast

A phone or laptop is the menu in your hand. A console is the menu board on the wall across the café: the same words need bigger letters, because you read them from the back of the room.

Think of it as The menu board on the wall across a café, instead of the menu in your hand

Run the cell. The heights are the picture heights of a 16:9 screen: 19.4 cm for the 15.6 inch laptop and 68.5 cm for the 55 inch TV.

Luau
local function pixelLooks(heightCm, rows, distanceCm)
	-- how tall one pixel looks: centimetres of screen per centimetre away
	return heightCm / rows / distanceCm
end
 
local laptop = pixelLooks(19.4, 1080, 60)
local tv = pixelLooks(68.5, 1080, 300)
print(string.format("TV needs %.2f times the pixels", laptop / tv))
Figure 2.1. Expected output: TV needs 1.42 times the pixels

Beacon Yard already has a lever for this. The Larger text setting multiplies every registered label by Config.LARGE_TEXT_SCALE, which is 1.3. That is close to the 1.42 the distance asks for. A good default for a TV is to start with Larger text on, and let the player turn it off.

The shop buttons use 24 px text. Using the 1.42 factor from the cell, how many pixels should that text be on the TV to look as big as it does on the laptop? Round to a whole pixel.

Answer

34 px (within 0.5). 24 × 1.416 is about 34 px. Larger text at 1.3 gives 31 px, which is close; a studio would check it on a real TV before shipping.

Open this step in lesson mode · Link to this step · This confused me

3The edges a TV may cut

Roblox has a better signal than pixel counts. GuiService.ViewportDisplaySize is Small on most phones and tablets, Medium on most laptops and monitors, and Large on most TVs2. The older GuiService:IsTenFootInterface() is superseded: it returns true on any console, however the player is using it3.

Size is half the problem. Some TVs do not show the picture all the way to the edges, so the guidelines ask you to keep UI inside the TV-safe areaTV-safe areaThe part of the picture every TV shows. Some TVs cut off the outer edges, so essential UI stays inside.Think of it as the part of the wall a pillar never hides.1. They give no number. Microsoft's guidance for Xbox apps does: keep essential UI out of the outer 5 percent of each edge4. On a 1920 by 1080 picture that is 96 px from the sides and 54 px from the top and bottom.

Now read where Beacon Yard puts its stats panel:

	panel.AnchorPoint = Vector2.new(0, 0)
	panel.Position = UDim2.fromOffset(16, 16)
	panel.Size = UDim2.fromOffset(460, 0)
Figure 3.1

The panel sits 16 px from the left edge, and the toasts sit 20 px above the bottom edge. ScreenGui.ScreenInsets keeps UI clear of phone notches and the Roblox top bar, but its documentation says nothing about TV overscan, so do not count on it here.

On a 1920 px wide picture, the safe area starts 96 px in. Beacon Yard's stats panel starts 16 px in. How many pixels further right must it move?

Answer

80 px. 80 px. Placing it at a scale of 0.05 instead of a 16 px offset keeps it 5 percent in on every screen width.

Open this step in lesson mode · Link to this step · This confused me

4A menu you walk one step at a time

Client sideRemember: A ten-foot console screen is the menu board on the wall across a café, instead of the menu in your hand.

On the café board, big letters and a clear margin are all you need. Look at the board idea a little longer, though, because a console player does not only read the menu. They drive it with four directions, select and back, one press at a time, and Roblox asks that every interactive element be reachable that way1.

Draw Beacon Yard's two menus as gamepad links. The shop is a column (Speed, Shield, Coin Pack, Speed Pass, Close). When it opens on a gamepad it selects Speed, and B closes it through the CloseShop action. The settings panel is different:

		"OpenSettings",
		Controls.onPress(function()
			panel.Visible = not panel.Visible
			if panel.Visible and UserInputService.GamepadEnabled then
				GuiService.SelectedObject = buttons[1]
			elseif not panel.Visible and GuiService.SelectedObject ~= nil then
				if GuiService.SelectedObject:IsDescendantOf(panel) then
					GuiService.SelectedObject = nil
Figure 4.1
The settings panel as gamepad linksTwo cyan client boxes, Reduced motion and Larger text, joined by up and down links. A dashed link from Larger text to a Close box is missing, and nothing is bound to B.down / upmissingReduced motionselected on openLarger texttogglePanel closedB? none bound
Figure 4.2. Two toggles that link to each other and to nothing else. No Close button, and nothing listens for B.

There is no Close button and nothing bound to B. The only way out is the same D-pad up that opened the panel, and while a menu holds the selection, the D-pad is also what moves the highlight. That is a dead endDead end (gamepad menu)A menu button from which a gamepad player has no way to close the menu.Think of it as a corridor with no exit sign and a door that only opens from the other side. a player should never have to puzzle out.

Which change makes Beacon Yard's settings panel work like its shop for a gamepad player?

  1. Bind a CloseSettings action to ButtonB while the panel is open, unbind it on close, and clear the selection
  2. Make the two toggle buttons bigger
  3. Set GuiService.AutoSelectGuiEnabled to false
  4. Move OpenSettings from DPadUp to ButtonA
Answer

Bind a CloseSettings action to ButtonB while the panel is open, unbind it on close, and clear the selection. Copy the shop: bind B while the panel is open, and on close unbind it and clear GuiService.SelectedObject so the stick moves the character again.

Open this step in lesson mode · Link to this step · This confused me

5Fence the highlight in

A second guard keeps the highlight inside a panel. Any frame can become a selection groupSelection groupA GUI container with SelectionGroup set to true, whose SelectionBehavior properties decide whether gamepad selection may leave it.Think of it as a fenced pen: the highlight can move freely inside, and the gate decides whether it can wander out.: set SelectionGroup = true and its SelectionBehaviorUp, Down, Left and Right properties apply. Escape, the default, looks inside the group first and leaves when nothing fits. Stop keeps the selection inside5. For a modal panel such as settings, Stop on all four sides is the usual choice.

Roblox also offers a virtual cursor as an alternative to directional selection, and the guidelines suggest bespoke navigation for unusual layouts1. For a column of buttons, directional selection is the better fit.

You set SelectionGroup = true and every SelectionBehavior to Stop on the settings panel, then press down on Larger text. Nothing looks different from before. Why?

  1. No other selectable button is on screen, so even Escape found nowhere to go; Stop protects the panel when one is added later
  2. Stop only works when GuiService.AutoSelectGuiEnabled is false
  3. SelectionGroup is ignored on frames that use UIListLayout
  4. SelectionBehavior only applies on PlayStation controllers
Answer

No other selectable button is on screen, so even Escape found nowhere to go; Stop protects the panel when one is added later. Today Escape and Stop behave the same, because nothing else is selectable. The fence matters the day someone adds a button to the HUD.

Now test the café analogy against the last two steps. The board picture explained text size and margins well. Answer before you open the breakdown.

Where does it break?“The menu board on the wall across a café, instead of the menu in your hand” is a good picture of a ten-foot console screen. Where does it stop being true?

It breaks here. A menu board is only read. A console menu is also walked one step at a time with a D-pad, so it can trap the player in a dead end and needs a way back, which no board has.

The true model. A console screen is read from far away and driven by sequential gamepad navigation. Size and margins answer the distance; selection links, selection groups and a Back button answer the navigation.

Which console problem does the café menu board picture not explain at all?

  1. A settings panel the player cannot get out of with a gamepad
  2. A coin counter too small to read from the sofa
  3. A stats panel cut off by the edge of some TVs
  4. Text that needs about 1.4 times more pixels on the TV
Answer

A settings panel the player cannot get out of with a gamepad. The board covers distance. Navigation (focus, selection groups, dead ends and Back) needs its own model: a graph of buttons you walk one press at a time.

Open this step in lesson mode · Link to this step · This confused me

6Before you switch Console on

Console reach is opt-in. Which devices can play is a setting of your experience, and the Creator Hub's activity history logs every change to its playable devices6. Before you turn Console on:

  • Content ratings. Games designed for consoles always need content ratings, or they risk being removed from consoles1.
  • No chat window. Roblox asks you to disable the chat window for console games, however you customise chat. The chat window and input bar can be switched off in Studio or from a script7.
  • Button icons that match the pad. UserInputService:GetImageForKeyCode() returns Roblox's Xbox or PlayStation icon for a key code, so a hint never shows the wrong button1.
  • Haptics, sparingly. A HapticEffect can rumble the pad for the drone's hit8. Constant vibration annoys players, so keep it for moments that matter1.

Beacon Yard uses chat for one game message. When a drill starts, RoundService asks AnnounceService to post a system line:

		pcall(AnnounceService.say, "Drill started")
Figure 6.1

RoundService announces "Drill started" through AnnounceService, which writes a system line in the chat window. With the chat window off on console, how does a console player know the drill began?

  1. The HUD's Phase stat changes from Idle, because the HUD reads the round phase separately
  2. They don't; AnnounceService must be rewritten before console launch
  3. Roblox shows system messages as pop-ups when the chat window is off
  4. The beacon's ProximityPrompt reads the chat line aloud
Answer

The HUD's Phase stat changes from Idle, because the HUD reads the round phase separately. Never make chat the only place important news appears. In Beacon Yard the Phase stat already covers the drill start.

Open this step in lesson mode · Link to this step · This confused me

7A short VR check

Roblox runs VR through OpenXR, so Quest headsets and PC VR headsets share one implementation9. You will not build a VR mode here. You will check what a headset player meets in Beacon Yard.

  • Scale feels real. In VR one stud is 0.3 m / Camera.HeadScale10. The drone's 12 studs per second becomes a speed a player feels in their stomach.
  • The camera belongs to the player's head. Roblox's default camera scripts support the comfort options (vignette, stepped rotation, a fixed third-person camera), and replacing them opts you out of those updates9. Tilting or rolling a VR player's view can make them dizzy10.
  • Beacon Yard's Zoom. CameraClient tweens FieldOfView between 70 and 50 when you press Q or Y. That is a deliberate change to what the player sees, the kind of camera motion comfort settings exist to soften. Turn it off when VRService.VREnabled is true (a property you can only read in a LocalScript)11.
  • Performance. Quest's Auto Quality Mode aims for at least 72 frames a second, and the guidelines recommend streaming, fewer draw calls and fewer transparent parts9.

Beacon Yard's drone moves at DRONE_SPEED = 12 studs per second. With HeadScale = 1, one stud is 0.3 m in VR. How fast does the drone come at a headset player, in metres per second?

Answer

3.6 m/s (within 0.05). 3.6 m/s, a fast run. On a flat screen the drone is a threat; in a headset it is a thing rushing at your face, which is worth testing on a real headset before you enable VR.

Open this step in lesson mode · Link to this step · This confused me

8Choices, and what studios do

Other ways pros do this

OptionWhat it isWhen pros pick itTrade-offs
Default directional selectionRoblox moves the highlight to the nearest selectable button in the pressed direction.Simple columns and grids, like Beacon Yard's shop.Odd layouts can jump to a surprising button; test every direction.
Explicit NextSelection linksSet NextSelectionUp, Down, Left and Right on each button.Layouts where the nearest button is not the logical next one.Every new button needs its links updated, or it becomes unreachable.
Selection groups with StopFence the highlight inside a panel with SelectionGroup and SelectionBehavior.Modal panels: shop, settings, dialogs.Every fenced panel needs a Close button or a bound Back action.
Virtual cursorA pointer the stick moves, built into Roblox.Dense or free-form UI such as maps and inventories.Slower than directional moves for a simple list.

You want Beacon Yard to start with Larger text on when it runs on a TV. Which value should the client read?

  1. GuiService.ViewportDisplaySize, and treat Large as a TV
  2. GuiService:IsTenFootInterface()
  3. UserInputService.GamepadEnabled
  4. workspace.CurrentCamera.ViewportSize.Y >= 1080
Answer

GuiService.ViewportDisplaySize, and treat Large as a TV. Read GuiService.ViewportDisplaySize. Large covers most TVs, whatever input the player uses.

Open this step in lesson mode · Link to this step · This confused me

9Build along: menus with a way out

Open your own copy of the finished game. Choose Test > Device Simulator to show the toolbar above the viewport. The toolbar is available in the full release. The Controller Emulator can emulate Xbox, PS4 and PS5 pads, Quest controllers and an Android TV remote12.

Roblox Studio
Roblox Studio playing Beacon Yard at sunset with Device Simulator set to Xbox One and the Controller Emulator showing its Xbox button map on the right. The shop is open in the middle of the screen with the Speed button selected by a bright selection ring.

Select a numbered pin, or a row below, to read what it marks.

Figure 9.1.

Beacon Yard on a simulated console: the shop opened with the X button, Speed selected, and the Controller Emulator lighting up the pad.

Build along

m14-ship

  • src/client/SettingsGui.luau
  • src/client/Controls.luau
  1. In the Device Simulator toolbar, pick a Console device. Open Virtual controller from the toolbar or Controller in the Emulation tab, then choose Xbox. Press Play, click the emulator so it has focus, and drive everything from the pad: walk to the Quartermaster, open the shop, close it, then open Settings and try to back out. Also note what D-pad up does now.

    You should see X at the Quartermaster opens the shop with Speed selected, and B closes it. D-pad up opens Settings with Reduced motion selected, and B leaves the panel open.

  2. In SettingsGui.luau, set panel.SelectionGroup = true and all four SelectionBehavior properties to Enum.SelectionBehavior.Stop. In Controls.luau, add a CloseSettings action on Enum.KeyCode.ButtonB with no touch button (copy CloseShop, and add the name to ActionName). Bind it when the panel opens; unbind it and clear GuiService.SelectedObject when it closes.

    You should see Pressing down on Larger text keeps the highlight on Larger text, and B closes the Settings panel and clears the selection so the stick moves the character again.

Open this step in lesson mode · Link to this step · This confused me

10Build along: text, margins and VR

Now the screen itself. Keep the console device and the Xbox pad from the last step.

Build along

m14-ship

  • src/client/Accessibility.luau
  • src/client/Hud.luau
  • src/client/CameraClient.luau
  1. In Accessibility.start, next to the line that seeds ReducedMotion from GuiService.ReducedMotionEnabled, read GuiService.ViewportDisplaySize inside a pcall, print it, and when it is Enum.DisplaySize.Large request LargeText once, with the same "only send a true" rule. The docs do not say which size Device Simulator reports for a console, so if yours reads Medium, test the branch by comparing against Medium for one run, then put Large back.

    You should see The Output shows the display size. When it reads Large, Settings already shows Larger text: on when you open it, and the shop's 24 px button text becomes 31 px.

  2. In Hud.luau, change the stats panel's position from UDim2.fromOffset(16, 16) to UDim2.fromScale(0.05, 0.05), and the toasts' from UDim2.new(0.5, 0, 1, -20) to UDim2.fromScale(0.5, 0.95). Switch between a phone, a desktop and a console device and check each.

    You should see The stats panel starts 5 percent in from the left and top edges, and the toasts sit above the bottom 5 percent, on every simulated device.

  3. In CameraClient.luau, read game:GetService("VRService").VREnabled and skip binding the CameraFieldOfView action when it is true. Leave everything else alone. If you have a headset, try a drill in it before you change anything else.

    You should see On your desktop, Q still zooms between 70 and 50, because VREnabled is false there.

Put the steps to take Beacon Yard to consoles in a sensible order.

  1. Complete the content ratings questionnaire
  2. Fix dead ends and text size, and test with Device Simulator and Controller Emulator
  3. Turn off the chat window for console players and move anything important out of chat
  4. Test on a real console and TV, then turn on Console in the experience's playable devices
Answer

1. Fix dead ends and text size, and test with Device Simulator and Controller Emulator 2. Turn off the chat window for console players and move anything important out of chat 3. Complete the content ratings questionnaire 4. Test on a real console and TV, then turn on Console in the experience's playable devices. Fix and test in Studio, remove console blockers, get rated, then verify on real hardware before players can see it.

Open this step in lesson mode · Link to this step · This confused me

11Challenges and recap

Fix sameLookPx so it compares how big a pixel looks from each seat, not only the distances. The laptop and TV are the ones from this lesson.

Luau
local LAPTOP = { heightCm = 19.4, rows = 1080, distanceCm = 60 }
local TV = { heightCm = 68.5, rows = 1080, distanceCm = 300 }
 
local function sameLookPx(px, from, to)
	-- Bug: this only compares distances. A pixel's look depends on
	-- its height (heightCm / rows) divided by the distance.
	local factor = to.distanceCm / from.distanceCm
	return math.round(px * factor)
end
 
print("24 px on the laptop is", sameLookPx(24, LAPTOP, TV), "px on the TV")
Figure 11.1. Run it in the lesson view or in the Studio command bar. The lesson view checks it with tests.

Level 1, Apprentice

Challenge

Fix sameLookPx in the sofa-check cell so all three tests pass.

Start from
The game at milestone m14 (download)
Check it here
Run the code cell in the lesson view; the challenge completes when it passes. No Studio needed.

Done means

  • sameLookPx uses each screen's heightCm / rows / distanceCm
  • 24 px on the laptop gives 34 px on the TV, and 18 gives 25
  • All three assertions in sofa-check pass

Hints

  1. Work out how tall one pixel looks on each screen (heightCm / rows / distanceCm); the factor is from divided by to.
  2. math.round(24 * 1.416) is 34.
Solution
luau
local factor = (from.heightCm / from.rows / from.distanceCm) / (to.heightCm / to.rows / to.distanceCm)

Level 3, Professional

Challenge

Write the four rules in challenges/work/console_nav.luau. The test draws Beacon Yard's real shop and settings panels as gamepad links, plus a pause menu with a dead end and a link to a missing button. The written solution is challenges/solutions/console-vr.md. In Play, run game.ServerScriptService.RunGameTests:Invoke("console-vr", "console-vr-nav") and paste the pass code here.

Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("console-vr", "console-vr-nav") in the server command bar. Copy the pass code from Output.

Done means

  • reachable walks up, down, left and right links from the start, ignores links to missing buttons, and returns the names sorted
  • deadEnds lists every reachable button that cannot reach a closer, and nothing when B closes the menu
  • The real m14-ship settings panel reports both toggles as dead ends, and the shop reports none
  • sameLookPx and inSafeArea match the lesson's laptop, TV and 5 percent rules
  • challenges/console-vr.luau prints TEST PASS for every check

Hints

  1. reachable is a breadth-first walk: keep a seen set and a queue, and skip a link whose name is not in menu.buttons.
  2. For deadEnds, run reachable again from each reachable button and look for any name in menu.closers.
  3. inSafeArea: x and y at least 5 percent of the screen, and x + w and y + h at most 95 percent.

Retiring the analogy

You no longer need “the menu board on the wall across a café, instead of the menu in your hand”. A console screen is read from far away and driven by sequential gamepad navigation. Size and margins answer the distance; selection links, selection groups and a Back button answer the navigation.

Recap

  1. A TV is read from about 3 metres away: pixel-based scaling cannot see that, so read GuiService.ViewportDisplaySize and treat Large as a TV.
  2. Text needs about 1.4 times the pixels on a 55 inch TV at 3 m; Beacon Yard's Larger text (1.3) is the lever, switched on by default for Large.
  3. Keep essential UI out of the outer 5 percent of a TV picture: scale positions, not 16 px offsets.
  4. Every menu needs a way out from every button: a Close button reachable by D-pad, or B bound while it is open, and a selection group with Stop for modal panels.
  5. Console needs content ratings and no chat window; VR needs a comfortable camera, so Beacon Yard skips its FOV zoom when VREnabled is true.

A ten-foot console screen is the menu board on the wall across a café, instead of the menu in your hand, until a menu board is only read. A console menu is also walked one step at a time with a D-pad, so it can trap the player in a dead end and needs a way back, which no board has.

Next UI frameworks, part 1: React-lua, elements, props and state

Open this step in lesson mode · Link to this step · This confused me