fireclickdetector
Fires a ClickDetector from any distance, with optional distance control and the documented mouse or hover event.
Syntax
fireclickdetector(clickDetector: ClickDetector, distance?: number, event?: string) -> nil
Parameters
| Parameter | Type | Description |
|---|---|---|
clickDetector | ClickDetector | The detector to fire. Its parent BasePart is also accepted. |
distance | number? | Activation distance in studs. Defaults to 0, which bypasses MaxActivationDistance. |
event | string? | "MouseClick" (default), "RightMouseClick", "MouseHoverEnter" or "MouseHoverLeave". |
Returns
No return value.
Description
The VM moves the cursor to the detector's on-screen position and sends the requested mouse event. During the call it temporarily adjusts the detector's MaxActivationDistance (bypassed for 0, set to the supplied value otherwise), then restores the distance and the cursor.
The part or detector must be on-screen, and the call requires Hybrid Luau and a focused game window.
Example
local cd = workspace.Button.ClickDetector
-- Standard left click from 0 studs distance
fireclickdetector(cd)
-- Right click
fireclickdetector(cd, 0.0, "RightMouseClick")
-- Hover enter / leave
fireclickdetector(cd, 0.0, "MouseHoverEnter")
fireclickdetector(cd, 0.0, "MouseHoverLeave")
Notes
- Accepts either the ClickDetector or its parent BasePart.
0bypasses the activation distance; a positive value sets the temporary activation limit.- Hover events are produced by moving the cursor over the part, so the entry and exit transitions may both occur before the cursor is restored.
- Requires Hybrid Luau and a focused Roblox window.