basically my script is like this (Keep in mind some parts of this have been shortened or modified for ease of understanding):
debug = false firing = false
IfTheGUIHasMouseDown(function() if debug = true then return end debug = true firing = true while firing = true do if Ammo ~= 0 then fire() wait(0.1) firing = false end end end)
IfTheMouseIsLiftedFromGUI(function() firing = false if debug = true then wait(0.1) debug = false end end)
======= My issue here is that I need to prevent the gun from having double fire. The debug works if you double click the GUI slowly, but if you're fast enough the debug simply doesn't work. From my understanding when MouseButton1 is lifted debug shouldn't become false for another 0.1 seconds, but that doesn't happen. Help?
There is no limit to debounce time. The only reason it wouldn't be working would be if there is a delay before the debounce is actually triggered.
debounce=false mouse.Button1Down:connect(function() if not debounce then debounce = true -- instant print("clicked") wait(1) debounce=false end end)