ClickDetectors randomly don't function

Hello. I’ve been recently running into a problem where using scripted ClickDetectors will sometimes decide to not function with no error given. This randomly happens with one or both buttons, and I’m not sure why. If anyone could tell me why this is or what I’m doing wrong, please let me know. Any help is appreciated. Thank you.

Attached below is an example of one button working but the other idling, as well as what the code is trying to do.

dfbsdghdfb
ghfdsfghnfdcncvn

For some reason the video won’t upload. I’ll try to figure out some way to upload it if need be.

You’re setting the MaxActivationDistance to 0? Is that when it’s no longer working, like does it only work once? Cause that’s why.

Try moving Debounce = false here:
41353cffe2c642f816ddfe3ead19a02ffe258a04

But debounce won’t work correcty then… wait

It’s being set to 0 temporarily for the debounce.

Alright, is this not the full code? Cause all that can be seen here is the set to 0 for Button1 then Button2 getting set to 25. If the other suggestion above doesn’t work out, it would be helpful if there was more context.

It’s not the full code, you are correct. Both of the activation distances are flipped when the second button gets pressed.

Ah! Well you shouldn’t be defining debounce globally. There should be a new debounce value for each of the click detector functions. Whenever you’re dealing with multiple functions they should never share a debounce value, they should all have their own because they’re clicked at different times if that makes sense.

1 Like

So you’re saying to make two separate local variables for the click detectors? That doesn’t seem to be working either.

Two separate local variables for the click detectors debounces. So underneath each function you should locally define debounce as false, not globally on line 7 like you are right now.


Like this?

1 Like

Yeah, it still isn’t working. I’ll try to find another solution since this has literally never happened to me before.

Alright so a friend of mine helped with the solution, turns out it was a collision issue with the button, which is weird because at times it would work but at other times it wouldn’t…

Regardless, I appreciate all of the help and support from you both. It really means a bunch. Farewell.