Open Asterune
ClickDetector

ClickDetector

Detects clicks on a parent part.

Creatable
Instance.new("ClickDetector")
Inherits
Instance
Replication
Standard

Behavior

ClickDetector detects pointer interactions with its parent part. MouseClick fires on the server and passes the player who clicked.

Use ProximityPrompt when the interaction needs a visible label and keyboard activation.

Summary

Members5
Properties1
Methods1
Events3
  • MouseClick: RBXScriptSignalparallel read

    Fires on the server when a player clicks the parent part.

  • MouseHoverEnter: RBXScriptSignalparallel read

    Fires when a player moves the pointer onto the parent part.

  • MouseHoverLeave: RBXScriptSignalparallel read

    Fires when the pointer leaves the parent part, whether or not it was clicked.

Properties

MaxActivationDistance

ClickDetector.MaxActivationDistance: number = 32

The maximum distance, in studs, from which a player can activate the detector.

Methods

GetExecutionGroup

ClickDetector:GetExecutionGroup(): ExecutionGroup?

Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.

Events

MouseClick

ClickDetector.MouseClick: RBXScriptSignal

Fires on the server when a player clicks the parent part. The engine supplies the player argument.

MouseHoverEnter

ClickDetector.MouseHoverEnter: RBXScriptSignal

Fires when a player moves the pointer onto the parent part.

MouseHoverLeave

ClickDetector.MouseHoverLeave: RBXScriptSignal

Fires when the pointer leaves the parent part, whether or not it was clicked.

Inherited members

Inherited47

Example

Luau
-- Server Script under a Part.
local detector = Instance.new("ClickDetector")
detector.Parent = script.Parent
detector.MouseClick:Connect(function(player)
  print(player.UserId)
end)

ProximityPrompt · BasePart · Player