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

# fireclickdetector

Dispatches a click or hover event on a `ClickDetector`.

```luau theme={null}
fireclickdetector(detector: ClickDetector, distance: number?, event: string?): ()
```

The `event` argument names which signal on the detector fires. Pass one of `"MouseClick"`, `"RightMouseClick"`, `"MouseHoverEnter"`, or `"MouseHoverLeave"`. When omitted, it defaults to `"MouseClick"`.

## Parameters

| Parameter  | Type            | Description                                                    |
| ---------- | --------------- | -------------------------------------------------------------- |
| `detector` | `ClickDetector` | The detector to dispatch the event on.                         |
| `distance` | `number?`       | Simulated activation distance. Defaults to `0`.                |
| `event`    | `string?`       | One of the four valid event names. Defaults to `"MouseClick"`. |

## Returns

<code title="the function does not return a value.">void</code>

## Example

In a tycoon, every upgrade has a buy button you walk up to and click. Fire `MouseClick` on all of them and buy the whole tycoon from spawn.

<CodeGroup>
  ```luau Example 1 theme={null}
  <<<<<<< HEAD
  fireclickdetector(workspace.Part.ClickDetector)
  =======
  -- fireclickdetector(detector: ClickDetector, distance: number?, event: string?): ()
  >>>>>>> 50e30f53759b0538759af25c9b271514aa2c9290
  ```

  ```luau Example 2 theme={null}
  for _, v in workspace.Tycoon.Buttons:GetDescendants() do
      if v:IsA("ClickDetector") then
          fireclickdetector(v, 0, "MouseClick")
      end
  end
  ```
</CodeGroup>

<Tip>
  Operates instantly regardless of player proximity restrictions.
</Tip>
