I’m trying to make a revised remake of a classical game I liked years ago. For the character customization, I want to allow players to click on mesh arrows in order to change the appearance of the customization rig. Although, the event (MouseClick) never fires, even when the MaxActivationDistance is set to infinity:
I’m confident this is because I disabled the character from automatically loading, so the distance between it and the arrow is undefined, but no workarounds really come to mind.
Not sure if this is helpful but…
This is what your code should somewhat look like, when the Part is clicked then it will print “Pressed”.
script.Parent.ClickDetector.MouseClick:Connect(function()
print("Pressed")
end)
Make sure that you have this code inside of a Server Script and not a Local Script.
I’m confident I’ve constructed the event’s function and bind correctly, except this is in a LocalScript. Here in the wiki, it states that both server and local scripts can listen for the event:
I’ll try your suggestion of listening for the event on the server shortly.
Oops, my bad. LocalScripts can interact with click detectors as long as they’re located in the appropriate place. I read further into your query and I also think that the issue is occurring because the player hasn’t been given a position, therefore it has no magnitude and the click detector wouldn’t work.
Have you tried testing it with the character loading in automatically?
Give your code a try with a character spawned. If it works, then you’re right on the reason for it not working.
If it is because your character isn’t spawned, then I suggest moving away from click detectors for this.
It doesn’t seem like wide enough of a case for it to be worth changing for Roblox in my opinion, but that’s not up to me. If you feel click detectors should be used here, then I would file a feature request with the lead top contributors for click detectors to work when you don’t have a character. Make sure one doesn’t exist before filing it, if you do.
Have you verified your LocalScript is actually running? That might be the issue.
This is most definitely not the issue. The same script that handles these MouseClicks is the one that handles the preloading and linear interpolation of the number; all in which are graphically present.
I gave it a try, and the event still doesn’t work. I’m going to conclude that it isn’t firing due to the pseudo cursor icon that always follows the mouse (existent to bypass the cursor icon change upon clicking GuiButtons).
So the script had a line that changed the value of the active property on a frame that transparently covered the two arrows to true which was what was intercepting the ability to actually click them, my bad.