The MaxActivationDistance property controls the maximum distance, in studs, between a
Player/Character|Character and the
ClickDetector for the character to be able to click it. This is used to limit from how far a player can interact with a ClickDetector.
For instance, a character within
10 studs of a ClickDetector with a MaxActivationDistance of
5 would not be able to click the ClickDetector because they are out of range. If, however, the MaxActivationDistance was
15, the character would be able to click it.
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
Then, the code connects the ClickDetector to several events, including changing the door’s
BasePart/Transparency when the player’s mouse hovers
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 and a
LocalScript as long as the script’s parent is the door