Set a constant of a live function (MUTATES STATE)
set-closure-constantPatch a Luau function's bytecode constant to change its behavior, like swapping a hardcoded string or redirecting a method call.
Instructions
WRITES LIVE GAME STATE. DANGER — Resolve a Luau expression to a function and overwrite one of its bytecode constants via setconstant. Constants are the literal values baked into a function's bytecode (numbers, strings, the names of globals/methods it calls). Patching one changes the function's behavior the next time it runs — e.g. rewrite a magic number, swap a hardcoded string, or redirect a method call by changing its name constant. This persists for the exact closure and can destabilize the game or trip anticheat; some executors only allow same-type replacement. Index is 1-based and must be within the function's constant count (inspect-closure reports ConstantCount). Requires setconstant. Pass confirm=true to proceed. Returns { Target, Index, ok } or { error }. Signature: { functionPath: string, index: number, value: { kind: "string" | "number" | "boolean" | "nil" | "raw", value: string | number | boolean? }, confirm: boolean, threadContext: number? }. Phase: act; cost=medium; idempotency=idempotent-write. Requires: active-client, resolved-target, explicit-mutation-approval. Capabilities: debug closure primitives. Produces: operation-receipt. Verify with: assert-state. Safety: MUTATING; writes live game/client state. On failure: inspect tool-schema for exact fields, defaults, constraints, and an invocation example.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | 1-based index of the constant to overwrite. Must be within the function's constant count (see ConstantCount from inspect-closure). | |
| value | Yes | New value for the constant. kind 'string'|'number'|'boolean' uses value literally; kind 'nil' sets nil; kind 'raw' treats value as a Luau expression evaluated for its result. Note: many executors require the replacement to be the same type as the original constant. | |
| confirm | Yes | Must be true to actually mutate the live function. When omitted or false, the tool refuses and changes nothing. | |
| functionPath | Yes | Luau expression resolving to the function whose constant you want to change, e.g. 'getsenv(game.Players.LocalPlayer.PlayerScripts.Main).fire' or a function found via scan-closures-by-source. Evaluated as `return <functionPath>`. | |
| threadContext | No | Optional Roblox thread identity for this call; omit it to use the server default. |