jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 18 Mar 2015 06:21 PM |
Everytime I use click detectors, the debounce never works properly and still registers multiple clicks in one click.
example:
clicked = false clickdetector.MouseClick:connect(function(player) if not clicked then clicked = true
--code
clicked = false end)
Or, is there a better method of clicking bricks without using the horrid click detector? |
|
|
| Report Abuse |
|
|
|
| 18 Mar 2015 06:22 PM |
clicked = false clickdetector.MouseClick:connect(function(player) if not clicked then clicked = true
--code
wait(1) clicked = false end) |
|
|
| Report Abuse |
|
|
jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 18 Mar 2015 06:25 PM |
@warspykingAlt
The code I have inside my click detector is 300 lines and waits 30 secs before activating again so, thats why I didn't put anything in there. Pretend there is. |
|
|
| Report Abuse |
|
|
|
| 18 Mar 2015 06:31 PM |
Sounds like you're doing something really wrong, click detectors shouldn't register more than 1 click per click.
If you're really set on an alternative however you could use GetMouse and mouse.hit and clicks and such, |
|
|
| Report Abuse |
|
|
jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 18 Mar 2015 06:34 PM |
Yeah I was thinking about using that.
This is my second time using click detectors, both times I've had problems with debouncing, and they were totally different scripts. |
|
|
| Report Abuse |
|
|
|
| 18 Mar 2015 06:35 PM |
There doesn't seem to be anything wrong at first glance, but the only reason I can think of at the moment is a mistake in the conditional statement structure. But between you and me, I personally prefer to do debounces like so:
clicked = false clickdetector.MouseClick:connect(function(player) if clicked then return end clicked = true
--code
wait(DelayTime) clicked = false end) |
|
|
| Report Abuse |
|
|
jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 18 Mar 2015 06:46 PM |
Okay I changed it, but this happens occasionally so I'll reply to this if I does not solve it. The code is now:
clicked = false clickdetector.MouseClick:connect(function(player) if clicked then return end clicked = true
--300 lines of code + waits
wait() clicked = false end) |
|
|
| Report Abuse |
|
|