ReferenceInstances

fireclickdetector

Fires a ClickDetector as if the local player had clicked or hovered over it.

Syntax

fireclickdetector(detector: ClickDetector, distance: number?, event: string?) -> ()

Also available as

fire_click_detector

Parameters

ParameterTypeDescription
detectorClickDetectorThe ClickDetector to fire.
distancenumber?The distance to report, in studs. Defaults to 0.
eventstring?"MouseClick" (default), "RightMouseClick", "MouseHoverEnter" or "MouseHoverLeave".

Description

The click is sent to the server like a real one, so server scripts connected to MouseClick receive the local player. Hover events are local and run only client connections.

Example

local detector = workspace.Button.ClickDetector
fireclickdetector(detector)
fireclickdetector(detector, 0, "RightMouseClick")

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.