Run Luau in Studio
runExecute Luau programs in Roblox Studio against the resident S API, building, querying, and verifying in one call and returning a JSON-safe summary.
Instructions
Run a Luau program in Roblox Studio against the resident S API. Ship whole programs, not micro-calls: build, query and verify in one call and return one JSON-safe summary. Globals: S, ARGS (= args), print/warn (captured), game, workspace, task.
dm 'edit' (default): ONE ChangeHistory recording — one undo step, rolled back on error/timeout. 'server' | 'client' | 'client:N': inside the live playtest, ephemeral (lost on stop, not undoable).
code or code_file (absolute path the bridge reads). Never heredoc Luau: \n in a string becomes a real newline → syntax_error "Malformed string".
S: get, ensure(path,class,props), find{root,name,class,tag,attr,max}, tree, props, new, set (unwritable props → result.unwritable), batchSet, clone, destroy (undoable), part, model, grid, placeOn(part,target,{align,gap}) sets a part on top of target, fits(cframe,size) → ok, blockers, overlaps(parts), script.get(path,{from,to})/set/patch/restart/create, emit, log, yield() (in long loops), wait, raycast, distance, remaining().
Geometry is enforced: parts intersecting parts (touching faces are fine) and BaseParts parented under BaseParts (use Models/Folders) are reported. geometry_policy warn (default) → result.geometry {overlaps[{a,b,depth}], nested[{path,parent}], checked, totals} + warnings; reject → rolled back, error geometry_violation with the report; off. Fix before moving on.
Result: {value, output[], duration_ms, changes{added,removed,paths}, undo: committed|cancelled|unavailable|n/a, ephemeral, dm, warnings?, detached?, unwritable?, geometry?}. response_format 'detailed' adds 12-component CFrames. Errors: {error:{code: luau_error|syntax_error|timeout|no_peer|cancelled|busy|geometry_violation|…, message, stack, output}}.
Still running after wait_ms (default 25000)? {job_id, status:'running'} — the program keeps running; use job. Edit-DM writes queue FIFO. dry_run (edit only) rolls back; a raw :Destroy() is neither rolled back nor undoable (use S.destroy). Several Studios connected: pass session.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dm | No | Target DataModel: 'edit' (default) | 'server' | 'client' (lowest-numbered) | 'client:N' | |
| args | No | Available to the program as ARGS | |
| code | No | Luau program. Globals: S (resident API), ARGS, print/warn (captured), game, workspace, task. A top-level `return` is captured. | |
| dry_run | No | edit DM only: run, then roll back | |
| session | No | Studio session GUID or unique prefix (default: the active hub; required for writes when several Studios are connected) | |
| wait_ms | No | Wait this long for completion before returning a {job_id,status:"running"} handle (default 25000) | |
| code_file | No | Instead of code: absolute path of a file holding the Luau (read by the bridge; UTF-8, BOM ok, ≤ 4 MB). No shell/JSON escaping touches it | |
| timeout_ms | No | Executor deadline in ms (default 30000) | |
| undo_label | No | ChangeHistory waypoint name (edit DM) | |
| geometry_policy | No | warn (default; env STUDIO_LIVE_GEOMETRY_POLICY): overlapping/nested parts → result.geometry + warnings; reject: such a run is rolled back (error geometry_violation); off: no check. Play DMs check only when set | |
| response_format | No | detailed: full 12-component CFrames ('c') in the returned value (default concise) |