Instances

fireclickdetector

Fires a ClickDetector interaction for the local player.

Syntax

fireclickdetector(detector: Instance, distance?: number, clickOption?: "mouseclick" | "rightmouseclick" | "mousehoverenter" | "mousehoverleave")

Arguments

NameTypeDescription
detectorInstanceInstance whose ClassName must be ClickDetector.
distance?numberOptional distance value. Defaults to 0 and is passed as a float for "mouseclick" and "rightmouseclick".
clickOption?"mouseclick" | "rightmouseclick" | "mousehoverenter" | "mousehoverleave"Optional interaction selector. It is read as a string, compared case-insensitively, and defaults to "mouseclick".

Description

Fires a ClickDetector interaction for the local player. The first argument must be an Instance whose ClassName is ClickDetector. distance is optional and defaults to 0. clickOption is optional, compared case-insensitively, and defaults to "mouseclick". Supported options are "mouseclick", "rightmouseclick", "mousehoverenter", and "mousehoverleave". Click options pass distance as a float to the Roblox click helper, while hover options ignore distance. If Players or Players.LocalPlayer is not available, the function returns without firing anything. An unknown clickOption also results in no interaction. The function returns nothing.

Call it with 3 parameter(s): detector, distance, clickOption. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Fire the default "mouseclick" interaction on a ClickDetector.

local detector = workspace.InteractivePart.ClickDetector

fireclickdetector(detector)