Yuari
Documentation
Docs/Closures/runbytecode

runbytecode

Loads bytecode and executes it, returning the chunk results.

Syntax

runbytecode(bytecode: string) -> any

Parameters

ParameterTypeDescription
bytecodestringLuau bytecode produced by dumpbytecode or the compiler.

Returns

TypeDescription
anyThe values returned by the loaded chunk, or nil and an error message.

Description

runbytecode loads a bytecode string and executes the resulting chunk immediately.

The chunk runs on the current thread and its return values are passed back to the caller. Load or runtime failures return nil plus an error message.

Example

local bytecode = dumpbytecode("return 21 * 2")
print(runbytecode(bytecode)) -- 42

Notes

  • Closure operations act on live Luau function objects; installed hooks remain active until restored.
  • Use dumpbytecode to produce a compatible bytecode string.