So, I'm making a gun script, and one of the features are automatic fire. It works fine, but if I click multiple times quickly during the firing intervals, it then fires 2 times quicker. It's supposed to break the firing loop if you release the mouse button, but if I release and reclick the mouse button quick enough, it doesn't work. Help, please?
Relevant Code:
while firing == true do -- make sure it's still firing
if reloading == true then break end
if script.Ammo.Value <= 0 then
script.Dry:Play()
break
end
for i = 1, projectilesPerShot do
if script.Ammo.Value <= 0 then
break
end
if i ~= 1 then
wait(multiProjectileDelay)
end
if firing == false then return end
script.Ammo.Value = script.Ammo.Value - 1
fire(pmouse)
end
wait(shotInterval)
end
Firing Break Function:
mouse.Button1Up:connect(function()
firing = false
end)
