generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Is there a proper way to debounce ClickDetectors?

Previous Thread :: Next Thread 
jmt99 is online. 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
warspykingAlt is not online. warspykingAlt
Joined: 16 Mar 2015
Total Posts: 37
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 is online. 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
warspykingAlt is not online. warspykingAlt
Joined: 16 Mar 2015
Total Posts: 37
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 is online. 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
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
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 is online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image