#Spam click of tool.activated

1 messages · Page 1 of 1 (latest)

unique nexus
#

When you spam click using the gun, the fire rate goes to an insane speed instead of waiting 0.1 sec. I'm thinking of a cooldown of checking tool.activated itself? I'm not too sure.

jolly rock
#

You dont check if CanShoot == true

#

if isShooting and not canShoot then return end

#

u can do that

unique nexus
#

sadly that gives the same outcome

#

@jolly rock

jolly rock
#

Ok instead of CanFire = false, do
Tool.ManualActivationOnly = true
wait(0.1)
Tool.ManualActivationOnly = false

#

Ah i understand. Before the while loop, do CanFire = false and after loop, CanFire = true

Remove all the CanFire things inside of the loop and in the begonning of the function, do if not CanFire then return end

unique nexus
#

I found this solution

#
local isShooting = false
local shootDelay = false
tool.Activated:Connect(function()
    if isShooting then return end --if false stop
    if currentAmmo > 0 then
        while isShooting do
            task.wait()
            if not shootDelay then
                isShooting = true
                playSFX("shoot")
                shootBullet:FireClient(player)
                currentAmmo -= 1
                updateGuiEvent:FireClient(player, currentAmmo, currentReserve)
                if currentAmmo == 0 then
                    isShooting = false
                end
                shootDelay = true
                task.wait(gunInfo["Fire Rate"])
                shootDelay = false
            end
        end
    end
end)