What do you want to achieve?
A button that only spawns one object.
What is the issue?
Players are using auto clickers on the button despite the ClickDetector’s MaxActivationDistance being put at 0 as soon as the button is pressed.
What solutions have you tried so far?
I’ve tried doing it with local scripts and trying to count how many objects come out.
Could this possibly be because of lots of parts in the game making it lag and creating a slower response?
Check the player’s position on the server and make sure they are near the click detector (32 studs). Never do stuff on the client as well and never trust them. Also recommend making an anti exploit.
Doesn’t the function connect every time the mouse button is clicked?
As @Nerkonl suggested, put a debounce, not a MaxActivationDistance change in there.
Chances are, this is an exploit. Most exploits have the feature of unlimiting all click detectors distances, and people can easily write a script to automatically click it for them.
Best method is to add a debounce and check to make sure the player is near the clickdetector.