clonefunction
Clones a Luau closure.
Syntax
Signature
clonefunction(Function: function) -> functionAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Function | function | Luau closure to clone. |
Returns
| Type | Description |
|---|---|
function | New Luau closure sharing the original upvalues. |
Notes
Creates a separate Luau closure with the same prototype, environment, and upvalue references as Function. Native C closures are rejected.
Example
Luau
local Result = clonefunction(function() return 42 end)
print(Result)