PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

RightMouseClick

The RightMouseClick event fires when a player presses and releases the right mouse button while the cursor is hovering over a BasePart or Model with a ClickDetector. Additionally, the Player’s Player/Character|Character must be within the ClickDetector/MaxActivationDistance|MaxActivationDistance of the clicked object. This event fires when using either a Script or LocalScript.

Related Events

  • If you want to check when a player left clicks on the ClickDetector, you can use the ClickDetector/MouseClick|MouseClick event.
  • If you want a function to fire when a player hovers on or off of the ClickDetector without clicking it you can use the ClickDetector/MouseHoverEnter|MouseHoverEnter and ClickDetector/MouseHoverLeave|MouseHoverLeave events.

Parameters

Name Type Default Description

The Player who right mouse clicked on the ClickDetector


Code Samples


Creating a ClickDetector Door

The code sample below demonstrates the functionality of a ClickDetector and its properties and events.

First the code creates a ClickDetector and set’s its Instance/Parent|parent to the door. It also sets the ClickDetector/MaxActivationDistance|maximum distance players can interact with the ClickDetector to 10 studs and set’s the ClickDetector’s ClickDetector/CursorImage|CursorImage to:

Custom cursor image

Then, the code connects the ClickDetector to several events, including changing the door’s BasePart/Transparency when the player’s mouse hovers ClickDetector/MouseHoverEnter|on and ClickDetector/MouseHoverLeave|off off the door. The player opens the door by ClickDetector/MouseClick|left clicking their mouse while over the ClickDetector and closes the door by ClickDetector/RightMouseClick|right clicking their mouse while over the ClickDetector.

This code works in a Script as long as the script’s parent is the door BasePart|Part.