LocalScript|LocalScripts to receive pointer input on 3D objects. They are placed inside
Folder|Folders. They can detect basic mouse events: enter, leave, left click and right click. Touch input on
UserInputService/TouchEnabled|TouchEnabled devices will also fire click events. For gamepad input, the right trigger button will fire the
ClickDetector/MouseClick|MouseClick event and center dot will trigger
Below is a simple template script for working with ClickDetectors. Paste it into a
Script or a
local clickDetector = workspace.Part.ClickDetector
print("You clicked me!")
ClickDetector/MaxActivationDistance|MaxActivationDistance can be used to limit the distance a player may be from a ClickDetector object before it is no longer clickable.
ClickDetector events fire on both the client and the server, even when
Workspace/FilteringEnabled|FilteringEnabled is on. Since
LocalScripts|LocalScript will only run if they are descendants of a
Player or Player’s 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.
If multiple ClickDetectors would detect a user input, only the deepest ClickDetector will fire events. If an action bound with
ContextActionService uses the same input as a ClickDetector, the action bound with ContextActionService will take priority over ClickDetector events. If two ClickDetectors are siblings, the first ClickDetector will take priority.
UserInputService/InputBegan will fire before ClickDetector events. Due to the nature of user input, you ought not depend on all
ClickDetector/MouseHoverEnter|MouseHoverEnter events to fire a matching
Sets the mouse icon that will be displayed when the mouse is hovered over this ClickDetector
Maximum distance between a character and the ClickDetector for the character to be able to click it
Fired when the
ClickDetector's parent is hovered upon by a player
Fired when a player’s mouse moves off of the