getfunctionbytecode(fn)
Returns the compiled instruction stream of a Lua function as a binary string.
Syntax
getfunctionbytecode(fn: function) -> string
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | function | Lua closure to read. C closures are rejected. |
Returns
| Type | Description |
|---|---|
string | Raw Proto instruction words. Empty only if the function has no code. |
Description
getfunctionbytecode dumps the instruction stream of the function's Proto. Import constants are already resolved inside Roblox protos, so the result is an analysis artifact rather than a reloadable bytecode chunk.
The result is deterministic: the same function always yields the same bytes, and different functions yield different bytes.
Example
local function first() return 1 end
local function second() return "yuari" end
print(#getfunctionbytecode(first) > 0)
print(getfunctionbytecode(first) ~= getfunctionbytecode(second))
Notes
- Throws for C closures.