|
| 18 Oct 2017 08:08 AM |
Hello!
I'm curious if there is a better way to do my debounce for my gun...when firing, I don't want to spam the mouse and have it end up firing a barrage.
I'm pretty dumb, thanks for the help!
Mouse.Button1Down:connect(function() if Active == true and Ammo > 0 and Firing == false and GlobalDebounce == true then GlobalDebounce = false Dead() Firing = true while Firing == true and Ammo > 0 do Singlefire() wait(FireRate/60) end end if Active == true and Ammo <= 0 then tool.MuzzleFlash.Smoke.Enabled = true Empty:Play() Firing = false end wait(2) GlobalDebounce = true end)
Mouse.Button1Up:connect(function() Firing = false end) |
|
|
| Report Abuse |
|
|
| |
|
mattscy
|
  |
| Joined: 06 May 2011 |
| Total Posts: 1079 |
|
|
| 18 Oct 2017 08:33 AM |
| is there anything wrong with the way youre doing it? |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2017 03:45 PM |
| I can click really fast and spam the shots and I was wondering if there was a different way to mitigate that. |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Oct 2017 08:15 PM |
| Set up a variable so that when you fire, if this variable is greater than x, it fires, and tick() is stored as the variable's value |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2017 08:17 PM |
| Whoops disregard that. Set up a variable with value tick(). When you click, see if tick() is greater than the variable. If it is, set the variable to tick() and call the function to fire the gun |
|
|
| Report Abuse |
|
|
|
| 18 Oct 2017 11:34 PM |
| Ok I tried it. The rounds travelled very slowly.. |
|
|
| Report Abuse |
|
|