Skip to content
Saiko

clonefunction

Returns a copy of the given function that behaves identically but is a distinct value, so hooking or comparing one does not affect the other.

Signature

luau
clonefunction<A..., R...>(fn: (A...) -> R...): (A...) -> R...

Parameters

fn(A...) -> R...

The function to duplicate.

Returns

function

Example

luau
local original = print
local copy = clonefunction(original)

print(copy == original) --> false
copy("still prints")