dumpbytecode
Compiles Luau source and returns its bytecode as a string.
Syntax
dumpbytecode(source: string) -> string
Parameters
| Parameter | Type | Description |
|---|---|---|
source | string | Luau source code to compile. |
Returns
| Type | Description |
|---|---|
string | The compiled Luau bytecode, or nil and an error message. |
Description
dumpbytecode compiles Luau source with the module compiler and returns the resulting bytecode string without executing it.
The bytecode can be passed to runbytecode later. Compilation failures return nil plus an error message instead of raising.
Example
local bytecode = dumpbytecode("return 1 + 1")
print(#bytecode)
Notes
- Closure operations act on live Luau function objects; installed hooks remain active until restored.
- The returned bytecode is tied to the current Luau bytecode version.