Check a Roblox UI layout before opening Studio
A cheap loop for agent-built UI: draft, preview as an image, fix, then generate the script once.
Running a generated script in Studio, looking at it, fixing it and running it again is slow. Most layout mistakes can be caught earlier, from an image, without Studio open.
The loop
- Draft.
decide_screentakes the request and returns an editable plan: roles, pieces and the arguments for composing. Set the width and height for the target orientation, and pin specific pieces if you already know what you want. - Preview.
preview_unitstakes the same arguments ascompose_unitsand returns a PNG, a list of pieces with their boxes, and an HTML file of the same layout. Your own text is drawn in, so the picture matches what Studio will show. - Fix. Change items, scale or container positions and preview again. Previews are free.
- Compose once. When the preview is clean, call
compose_unitswith the same arguments and run the script.
What to look for
- Overlaps you did not intend, and text that does not fit its piece.
- Warnings in the plan about copy that could not be placed, or labels that may be too small on a phone.
- An empty zone. A big window with a single button usually means something is missing.
- The basics: a visible close button, a title in the header, a name and price on every card.
Then read the script header
The generated script starts with a report. orphan means a layer was placed without its base. off-canvas and clipped mean positions or canvas size need fixing. duplicate-art means a piece is already drawn inside its parent's image. mixed-packs is a prompt to compare how the pieces look together. Fix the cause named there and compose again, rather than patching the output.
Frequently asked questions
How can an AI agent verify a Roblox ScreenGui layout without running Studio?
Call preview_units with the exact same arguments you intend to pass to compose_units. It is free and outputs a rendered PNG with custom copy drawn in, bounding boxes, overlap warnings, and an HTML inspection file.
What do orphan, clipped, and mixed-packs warnings mean in penui Luau output?
orphan means a child layer was placed without its parent base; off-canvas or clipped means items exceed the design canvas; duplicate-art means a piece is already baked into its parent PNG; mixed-packs warns when structural pieces come from different packs.
Does preview_units cost metered units?
No. decide_screen, search_units, get_unit, match_theme, suggest_combos, and preview_units are free. Only Luau generation calls (compose_units, compose_screen, get_luau) consume units.