> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# clonefunction

> Creates and returns a separate function value for the function passed as the first argument. The argument must be a function.

Creates and returns a separate function value for the function passed as the first argument. The argument must be a function.

## Syntax

```lua theme={null}
clonefunction(func: function): function
```

## Arguments

| Name   | Type       | Required | Description                                                    |
| ------ | ---------- | -------- | -------------------------------------------------------------- |
| `func` | `function` | Yes      | Function to clone. Passing a non-function raises a type error. |

## Returns

| Name    | Type       | Description                                                                      |
| ------- | ---------- | -------------------------------------------------------------------------------- |
| `clone` | `function` | New function produced by the newcclosure, C closure, or Luau closure clone path. |

## Example

Create a cloned closure from a function.

```lua theme={null}
local function greet(name)
    return "Hello, " .. name
end

local cloned = clonefunction(greet)
print(cloned("Real"))
```
