ReferenceClosures

newlclosure

Wraps any function in a new Luau function.

Syntax

newlclosure(func: function) -> function

Also available as

new_l_closure

Parameters

ParameterTypeDescription
funcfunctionThe function to wrap.

Returns

TypeDescription
functionA Luau function that forwards its arguments to func and returns its results.

Description

It is the Luau counterpart of newcclosure: the wrapper is a Luau function, so it can stand in where a Luau function is expected, such as a hook that must not have more upvalues than its target. Calling it calls func with the same arguments and returns the same results.

Example

local wrapped = newlclosure(print)
print(islclosure(wrapped))
wrapped("forwarded to print")

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