ClickDetectors weren’t working in my game with a controller, despite the DevHub saying that it should fire with RightTrigger.
For gamepad input, the right trigger button will fire the
MouseClick
event and center dot will triggerMouseHoverEnter
/MouseHoverLeave
.
Source: ClickDetector | Documentation - Roblox Creator Hub
After excruciating testing, I finally realized that having a custom ControlScript (LocalScript in StarterPlayerScripts named “ControlScript” removes the default player controller) was the issue.
Apparently, what the Hub claims is “default behavior” is actually set by the ControlScript, and you need to handle it yourself otherwise.
Once I knew it was something in the ControlScript, I had to pore over the default one to find what it did to handle ClickDetectors.
Turns out, you have to set ContextActionService:BindActivate() to Enum.KeyCode.ButtonR2 in order to get the expected behavior.
However, the documentation page for CAS:BindActivate() is faulty, so that wasn’t easy to figure out. it never mentions that it affects ClickDetectors.
Bind an
KeyCode
that can be used with anUserInputType
to activate aTool
(or aHopperBin
). When the respective key is pressed, it will fire theMouse.Button1Down
event on the mouse sent toTool.Equipped
(orHopperBin.Selected
). This in turn fires theTool.Activated
event ifTool.ManualActivationOnly
is not set to true.
Source: ContextActionService | Documentation - Roblox Creator Hub