ReferenceScripts

getfunctionbytecode

Returns bytecode for a single function.

Syntax

getfunctionbytecode(func: function) -> string

Parameters

ParameterTypeDescription
funcfunctionA Luau function.

Returns

TypeDescription
stringBytecode for this one function and the functions nested inside it.

Description

The result is a standalone bytecode chunk containing func as its main function, with its constants and the functions it defines. You can load it again or pass it to decompile.

Example

local function area(w, h)
    return w * h
end
print(#getfunctionbytecode(area))

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.