Skip to content

ClickDetector

Supported Class Other

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

7 Nova members · 1 modern Roblox members not implemented yet

Description

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.

Inheritance

Object → Instance → ClickDetector

Nova inheritance: Instance → ClickDetector

Known subclasses: DragDetector

Properties

CursorIcon Supported Property Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector.
CursorIcon: Content

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.

Roblox reference signature
CursorIcon: ContentId

Roblox documentation

MaxActivationDistance Supported Property Maximum distance between a character and the ClickDetector or DragDetector for the player to be able to interact with it.
MaxActivationDistance: float

Maximum 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.

Roblox documentation

Events

MouseClick Supported Event Fires when a player interacts with the parent of a ClickDetector or DragDetector.
MouseClick(Instance playerWhoClicked)

Fires when a player interacts with the parent of a ClickDetector or DragDetector.

This event fires from either a Script or LocalScript when a player interacts with a ClickDetector or DragDetector via the following inputs:

  • On platforms with a mouse, when the player left mouse clicks.
  • On TouchEnabled platforms, when the player taps.
  • On GamepadEnabled platforms, when the center dot is over the same model and the A button is pressed and released.

Note that the player's Character must be within the MaxActivationDistance of the detector.

Roblox reference signature
MouseClick(playerWhoClicked: Player)

Roblox documentation

mouseClick Supported Event Deprecated
mouseClick(Instance playerWhoClicked)

No description available.

Roblox reference signature
mouseClick(playerWhoClicked: Player)
Nova behaviour: Nova keeps this legacy member for compatibility. Roblox's modern deprecation wording may describe later Roblox behaviour; verify it against Nova before relying on the copied text.

Roblox documentation

MouseHoverEnter Supported Event Fires when the parent of a ClickDetector or DragDetector is hovered over by a player.
MouseHoverEnter(Instance playerWhoHovered)

Fires when the parent of a ClickDetector or DragDetector is hovered over by a player.

This event fires from either a Script or LocalScript when the parent of a ClickDetector or DragDetector is hovered over by a player. This does not entail explicit interaction with the detector, for which you can listen to either MouseClick and RightMouseClick events.

Due to the nature of user input, you should not depend on all MouseHoverEnter events firing a corresponding MouseHoverLeave event.

Roblox reference signature
MouseHoverEnter(playerWhoHovered: Player)

Roblox documentation

MouseHoverLeave Supported Event Fires when a player's cursor hovers off the parent of a ClickDetector or DragDetector.
MouseHoverLeave(Instance playerWhoHovered)

Fires when a player's cursor hovers off the parent of a ClickDetector or DragDetector.

This event fires from either a Script or LocalScript when a player's cursor hovers off the parent of a ClickDetector or DragDetector. This does not entail explicit interaction with the detector, for which you can listen to either MouseClick and RightMouseClick events.

Due to the nature of user input, you should not depend on all MouseHoverLeave events firing after a corresponding MouseHoverEnter event.

Roblox reference signature
MouseHoverLeave(playerWhoHovered: Player)

Roblox documentation

RightMouseClick Supported Event Fires when a player right clicks their mouse cursor on a ClickDetector or DragDetector.
RightMouseClick(Instance playerWhoClicked)

Fires when a player right clicks their mouse cursor on a ClickDetector or DragDetector.

This event fires from either a Script or LocalScript when a player right clicks their mouse cursor on a ClickDetector or DragDetector. Note that the player's Character must be within the MaxActivationDistance of the detector.

Roblox reference signature
RightMouseClick(playerWhoClicked: Player)

Roblox documentation

Inherited members

Inherited from Instance: 8 properties, 36 methods, 7 events. They are documented on the base class page.

1 modern Roblox member(s) are not implemented yet — expand to inspect

Members declared by Roblox's ClickDetector class (or by a missing base class) that Nova does not expose. Use this list to scope a migration; the compatibility guide has the recommended workaround.

Properties

Member Signature Status Notes Flags
CursorIconContent CursorIconContent: Content Not yet Sets the cursor icon to display when the mouse is hovered over the parent of this ClickDetector or DragDetector. Only supports ass… —

Roblox reference: ClickDetector

Generated from Nova's API dump and Roblox creator-docs. Nova-only members come from the engine's reflection metadata.