#[solved] How to solve automatic weapon problem

13 messages · Page 1 of 1 (latest)

warped dagger
#

So I'm making an automatic gun, right? but I noticed a problem with its integrity - that being, you can compromise the intended firerate by double clicking to make it fire much faster. I'm not sure how it happened, but I measured the shots per second and whenever I hold down lmb normally, perfectly fine (5 shots per sec with the occasional 6), but when you click a bit more, it's averaging 6 shots per sec with the occasional 5. Any solutions to prevent this?

#

btw heres the relevant code

#
function fire()
    if debounce == false then
        debounce = true -- lock period between shots
        idleTrack:Stop()
        
        --Playing all the necessary things        
        script.ShootSfx:Play()
        shootTrack:Play()
        shootTrack:AdjustWeight(1.2,.1)
        
        shots += 1
        
        wait(firerate)
        debounce = false
        
        -- Closing Up
        shootTrack:Stop()
        idleTrack:Play()
        idleTrack:AdjustWeight(1,.1)
    end
end

mouse.Button1Down:Connect(function()
    isFiring = true
    while isFiring == true do
        fire()
        wait()
    end
end)

mouse.Button1Up:Connect(function()
    isFiring = false
end)
dense mica
#

try

if debounce == true then return end
debounce=true

wait(firerate)
debounce=false
little hazelBOT
#

studio** You are now Level 6! **studio

dense mica
#

@warped dagger Let me know if things dont work

warped dagger
#

aight

#

though it is pretty late and i gotta get sleep

dense mica
#

oh ok toodles

warped dagger
#

oh damn it actually did work thx

dense mica
#

awesome sause

warped dagger
#

bye bye girlie!!!!!

dense mica
#

adios