Execute code and wait for the result
execute-and-waitRun Luau in a live Roblox client and wait for the structured result: success, returned value, printed output, and any error. Use for debugging or inspecting function returns in one call.
Instructions
Run Luau in the active Roblox client and WAIT for what happened, returning a structured result: { ok, returnValue, output, error? }. Unlike the fire-and-forget 'execute' tool, this reports success/failure, any error message, the FIRST value your code returns (encoded so Instances/Vector3/etc. survive), and the print()/warn() output it emitted. Output capture connects game:GetService("LogService").MessageOut to a buffer for the duration of the run, then disconnects — so it sees logs even when an executor routes print() to the Roblox console rather than swapping the global. The code is COMPILED FIRST via loadstring (a syntax error is reported as { ok = false, error } and nothing runs), then executed under pcall; a runtime error is reported in error, never as a tool failure. Use this for quick experiments, debugging, or calling a function and inspecting what it gives back in one round trip. Signature: { code: string, client: string?, agent: string?, threadContext: number?, timeoutMs: number? }. Phase: act; cost=medium; idempotency=contextual-write. Requires: active-client, explicit-mutation-approval, validated-source. Produces: operation-receipt. Verify with: assert-state. Safety: MUTATING; executes caller-selected behavior in the live client. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The Luau code to run. It may 'return' a value (the FIRST return comes back in `returnValue`, encoded) and may print()/warn() (captured into `output`). Do not JSON-encode anything yourself. | |
| agent | No | Optional. A stable label for WHICH agent is calling when several share this MCP session (e.g. 'researcher'). Gives that agent its own fair scheduling lane, its own persistent VM on each game, and its own queue budget, so co-tenant agents don't starve or clobber each other. | |
| client | No | Optional. Run on a specific connected client — its clientId OR username — for THIS call only, overriding your session's select-client binding without changing it. Lets multiple agents drive different games at the same time; omit to use your session's selected client. | |
| timeoutMs | No | Optional per-call deadline in milliseconds; omit it to use the tool or server default. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |