We use cookies on this site to enhance your user experience

ClickDetector

ClickDetector

ClickDetector allows both Script|Scripts and LocalScript|LocalScripts to receive user input. They are placed inside Model|Models, Folder|Folders, and BasePart|BaseParts. They mirror user input to the server through FilteringEnabled. They can detect basic mouse events: enter, leave, left click and right click.

If an action bound with /ContextActionService uses the same input as a ClickDetector, the bound action will take priority and the ClickDetector events will not fire.

With gamepad input, the right trigger button will fire the MouseClick event and center dot will trigger MouseHoverEnter/MouseHoverLeave.

LocalScripts can connect to ClickDetector events and they will fire on the client. Since LocalScripts only run if they are descendants of a /Player or Player’s Character, it’s not a good idea to put LocalScripts inside ClickDetectors. If you need a LocalScript to detect ClickDetector events, /StarterPlayerScripts may be a better place instead.

If multiple ClickDetectors would detect a user input, only the deepest ClickDetector will fire events. If two ClickDetectors are siblings, the first ClickDetector takes priority. Due to the nature of user input, you ought not depend on all MouseHoverEnter events to fire a matching MouseHoverLeave event.

Properties

Name Type Description
Content

Sets the mouse icon that will be displayed when the mouse is hovered over this ClickDetector.

float

Maximum distance between a character and the ClickDetector for the character to be able to click it.

Inherited from Instance

Archivable ClassName DataCost Name Parent RobloxLocked

Events

Name Type Description

Fires when a player left clicks on the ClickDetector.

Fired when the ClickDetector's parent is hovered upon by a player.

Fired when a player’s mouse moves off of the ClickDetector's parent.

Fires when a player right clicks on the ClickDetector.

Inherited from Instance

AncestryChanged Changed ChildAdded ChildRemoved DescendantAdded DescendantRemoving