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
The maximum distance, in studs, from which a player can activate the detector.
Returns this instance if it is an ExecutionGroup.
Fires on the server when a player clicks the parent part.
Fires when a player moves the pointer onto the parent part.
Fires when the pointer leaves the parent part, whether or not it was clicked.
Properties
MaxActivationDistance
ClickDetector.MaxActivationDistance: number = 32The 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: RBXScriptSignalFires on the server when a player clicks the parent part. The engine supplies the player argument.
MouseHoverEnter
ClickDetector.MouseHoverEnter: RBXScriptSignalFires when a player moves the pointer onto the parent part.
MouseHoverLeave
ClickDetector.MouseHoverLeave: RBXScriptSignalFires when the pointer leaves the parent part, whether or not it was clicked.
Inherited members
- Properties
- ArchivableClassNameNameParent
- Methods
- AddComponent()AddTag()ClearAllChildren()ClearTags()Clone()Destroy()FindFirstAncestor()FindFirstAncestorOfClass()FindFirstAncestorWhichIsA()FindFirstChild()FindFirstChildOfClass()FindFirstChildWhichIsA()FindFirstDescendant()GetAttribute()GetAttributeChangedSignal()GetAttributes()GetChildren()GetComponent()GetComponentChangedSignal()GetComponents()GetDebugId()GetDescendants()GetFullName()GetPropertyChangedSignal()GetReferencing()GetTags()HasComponent()HasTag()IsA()IsAncestorOf()IsDescendantOf()RemoveComponent()RemoveTag()SetAttribute()WaitForChild()
- Events
- AncestryChangedAttributeChangedChangedChildAddedChildRemovedDescendantAddedDescendantRemovingDestroying
Example
-- Server Script under a Part.
local detector = Instance.new("ClickDetector")
detector.Parent = script.Parent
detector.MouseClick:Connect(function(player)
print(player.UserId)
end)