---
title: "clonefunction"
description: "Clones a closure into a separate function object."
---

```lua
clonefunction(fn: function): function
```

---

## Aliases

None.

---

## Arguments

<ParamField body="fn" type="function" required>
  The function to inspect or wrap.
</ParamField>

---

## Returns

<ResponseField name="copy" type="function">
  A separate function closure referring to the captured state.
</ResponseField>

A closure clone is not a deep copy of captured tables or external state.

---

## Example

```lua
local function twice(x) return x * 2 end
local copy = clonefunction(twice)
print(copy(4))
```
