clonefunction

Clones a Luau closure.

Syntax

Signature
clonefunction(Function: function) -> function

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
FunctionfunctionLuau closure to clone.

Returns

TypeDescription
functionNew 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)