Compiles the script’s bytecode into a brand-new closure and returns it. The closure is a fresh copy, not the one the game is running, so calling it runs the script’s top-level code again in a clean environment. Handy for recovering a module’s return value without touching the live instance. Also registered as getscriptfunction.

Parameters

Instance
required
A LocalScript, ModuleScript, or Script with bytecode.

Returns

function
A new closure compiled from the script.

Example

Errors