fn. The copy behaves identically to the original
but is a distinct closure, so hooking or modifying one does not affect the other.
Parameters
function
required
The closure to copy. Both C and Luau closures are supported.
Returns
function
A new closure that calls through to the same underlying behavior as
fn.Behavior
- Independent identity. The clone is not equal to the original under
==, andcomparefunctionsis the way to confirm they still share behavior. - Hook state is preserved. If
fnis currently hooked, the clone reflects the same hooked behavior at the moment it is made, rather than copying a half-hooked state. - Executor origin carried. If the source is an Athena closure, the clone is tracked as one too, so caller and ownership checks continue to recognize it.
Example
Keep a pristine reference before hooking:Errors
Related
comparefunctions: confirm two closures are equivalent.hookfunction: redirect a function to a replacement.