> ## 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.

# compareinstances

Checks whether `a` and `b` are the same Roblox Instance.

```luau theme={null}
compareinstances(a: Instance, b: Instance): boolean
```

Calling `cloneref` on an Instance gives you a separate Lua reference. Roblox treats both as the same Instance, but using the `==` operator compares the objects themselves - so `original == cloneref(original)` will return `false`. `compareinstances` checks the Roblox Instances behind them instead.

Most commonly used after `cloneref` to confirm a clone and its original are the same Roblox Instance.

## Parameters

| Parameter | Type       | Description                     |
| --------- | ---------- | ------------------------------- |
| `a`       | `Instance` | The first instance to compare.  |
| `b`       | `Instance` | The second instance to compare. |

## Returns

`boolean` - `true` when both arguments are the same Roblox Instance; otherwise `false`.

## Aliases

* `checkinst`

## Example

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  local compareinstances = compareinstances(game:GetService("Players"), game:GetService("Players"))
  =======
  -- compareinstances(a: Instance, b: Instance): boolean
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  local players = game:GetService("Players")
  local cleanPlayers = cloneref(players)

  print(players == cleanPlayers)                  --> false
  print(compareinstances(players, cleanPlayers))  --> true
  ```
</CodeGroup>

<Tip>
  Bypasses standard Lua `==` reference inequality for cloned references.
</Tip>
