Skip to content

Class · inherits Instance

ClickDetector

Official docs ↗

An object that provides user input on in-experience BaseParts and Models.

About ClickDetector

ClickDetector allows Scripts and LocalScripts to receive pointer input on 3D objects through their MouseClick event. They work when parented to BasePart, Model, or Folder objects. They detect basic mouse events: enter, leave, left click and right click. Touch input on TouchEnabled devices also fires click events.

The default control scripts bind ButtonR2 to interact with ClickDetectors using ContextActionService.BindActivate, which can also be used to override this. When using gamepads, the center dot triggers MouseHoverEnter and MouseHoverLeave. The bound activation button fires MouseClick.

MaxActivationDistance can be used to limit the distance a player may be from a click detector before it is no longer clickable.

ClickDetector events fire on both the client and the server. Since a LocalScript will only run if it descends from a Player or player Character, it's usually not useful to put a LocalScript inside a ClickDetector, since the script won't run or the object won't be clickable. If you need a LocalScript to detect ClickDetector events, StarterPlayerScripts may be a better place instead.

Input Priority

If multiple ClickDetectors may detect user input, only the deepest will fire events. If two ClickDetectors are siblings, the first will take priority.

If an action bound with ContextActionService uses the same input as a ClickDetector, the action bound with ContextActionService will take priority over the click detector's events.

UserInputService.InputBegan will fire before ClickDetector events.

Properties 3

  • CursorIcon: ContentIdSets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector.

    Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector. If this property is left blank, the detector will use the default icon.

    To change the cursor icon, set this property to the asset ID of the image you'd like to use.

  • CursorIconContent: ContentSets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector. Only supports asset URIs.

    Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector. If this property is left blank, the detector will use the default icon.

    To change the cursor icon, set this property to the asset ID of the image you'd like to use. Only asset URIs are supported for this property.

  • MaxActivationDistance: floatMaximum distance between a character and the ClickDetector or DragDetector for the player to be able to interact with it.

    This property controls the maximum distance, in studs, between a Character and the ClickDetector or DragDetector for the player to be able to interact with it. For instance, a character within 10 studs of a ClickDetector or DragDetector with a max activation distance of 5 would not be able to use the detector because they are out of range.

Events 4

ClickDetector also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.