Blog / MCP Workflow 2 min read

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

  1. Draft. decide_screen takes 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.
  2. Preview. preview_units takes the same arguments as compose_units and 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.
  3. Fix. Change items, scale or container positions and preview again. Previews are free.
  4. Compose once. When the preview is clean, call compose_units with the same arguments and run the script.

What to look for

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.

Install the MCP server · All posts · RSS feed