getscriptclosure Synchronous
getscriptfunction
Create or retrieve a callable closure from a script Instance’s stored code. Use it when you need a function value for inspection rather than raw bytecode text.
Luau
getscriptclosure(script: ScriptInstance) -> Function?Parameters
| Parameter | Type | Description |
|---|---|---|
script | ScriptInstance | Script Instance with available stored bytecode. |
Returns
Function?A function, or nil when the script bytecode is unavailable.
Usage notes
Obtaining the closure is separate from calling it. Calling script code can have side effects, so inspect the result before invocation.
Example
Luau
local candidate = getscripts()[1]
if candidate then
local closure = getscriptclosure(candidate)
print("Closure available:", type(closure) == "function")
end