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

# cloneref

Returns a separate Lua reference to `instance` - Roblox treats both as the same Instance.

```luau theme={null}
cloneref(instance: Instance): Instance
```

Commonly written wrapping a service - `cloneref(game:GetService("CoreGui"))`. Considered industry-standard for all scripts written in a Roblox Executor context. [See more here](https://www.youtube.com/watch?v=Ny28cEovcu0).

## Parameters

| Parameter  | Type       | Description            |
| ---------- | ---------- | ---------------------- |
| `instance` | `Instance` | The Instance to clone. |

## Returns

[`Instance`](https://create.roblox.com/docs/reference/engine/classes/Instance)

## Aliases

* `clonereference`

## Example

<CodeGroup>
  ```luau Example 1 theme={null}
  local fake_players = cloneref(game:GetService("Players"))
  local real_players = game:GetService("Players")
  print(compareinstances(fake_players, real_players) -- uh false? I forgot
  ```

  ```luau Example 2 theme={null}
  local rs = cloneref(game:GetService("CoreGui"))

  for _, child in rs:GetChildren() do
      print(child.Name)
  end
  ```
</CodeGroup>

<Tip>
  Use `compareinstances(a, b)` to check whether two values are the same Instance - regular `==` returns `false` the moment one side has been through `cloneref`. The `cloneref` copy and the original point at the same Instance, so changes through either (setting properties, adding children, calling `:Destroy()`) show up on both.
</Tip>
