Roblox Wiki
Roblox Wiki
38,928
pages

The ClickDetector class is used to make an object able to be selected, and if applied, perform an action. To apply it, select a brick, then go to Insert > Object > ClickDetector. If you apply a script to purchase an object by clicking, then when you hover over the object, your cursor will turn to a hand, and if you click, the script will be executed. You can also use this technique on doors, e.g. placing a ClickDetector brick that when selected sets an object CanCollide setting to false, allowing passage. Good for making doors and such. It was released on April 2, 2008, alongside email verification and Sparkles light iconSparkles dark iconSparkles.[1] At an unknown date, the ClickDetector pointer was revamped.


Usage[]

When a player clicks a ClickDetector's parent brick, this event will fire including the player who clicked.

Example:

script.Parent.MouseClick:connect(function(player)
    print(player .. " has clicked the part!")
end)

Properties

CursorIcon: ContentId

Sets the image of the cursor when this ClickDetector is hovered.

  • Category: Image.
  • Serialization: can save and load.
  • Thread safety: read safe

CursorIconContent: Content

This class member is missing documentation. Create or add to its subpage at Class:ClickDetector/CursorIconContent.
  • Category: Image.
  • Serialization: can save and load.
  • Thread safety: read safe

MaxActivationDistance: float

The maximum distance a Player light iconPlayer dark iconPlayer's character can be from the ClickDetector's parent Part that will allow the Player's mouse to fire events on this object.

  • Category: Data.
  • Serialization: can save and load.
  • Thread safety: read safe

Events

MouseClick(playerWhoClicked: Player)

Parameters
NameTypeDescription
playerWhoClickedPlayerThe Player light iconPlayer dark iconPlayer that clicked on the detector.

This event is fired when the ClickDetector is clicked on. The player who clicked on the ClickDetector is given as the playerWhoClicked variable.

  • Thread safety: unsafe

MouseHoverEnter(playerWhoHovered: Player)

Parameters
NameType
playerWhoHoveredPlayer
  • Thread safety: unsafe

MouseHoverLeave(playerWhoHovered: Player)

Parameters
NameType
playerWhoHoveredPlayer
  • Thread safety: unsafe

RightMouseClick(playerWhoClicked: Player)

Parameters
NameType
playerWhoClickedPlayer
  • Thread safety: unsafe

mouseClick(playerWhoClicked: Player)

  • DeprecatedThis member will be phased out and should be avoided while it is still available.
Parameters
NameType
playerWhoClickedPlayer

Use MouseClick instead.

  • Thread safety: unsafe

External links[]

  1. Shedletsky, John (2008, April 2). "Verified Sparkle Places – Fantastic Release". From Roblox Blog. Archived from the original on October 20, 2019.