if (key == "f") then if (not isFiring) and (not cloakActive.Value) and (not shieldActive.Value) and (speed.Value < fireSpeed) then isFiring = true fire() wait(weaponsCooldown) isFiring = false end end
Need it to make a Viper weapons system from Battlestar Galactica
I'm not entirely sure what system you have set up, but it's pretty easy to do. Just use a while loop to make yourself keep firing.
local fire = false mouse.Button1Down:connect(function() fire = true end) mouse.Button1Up:connect(function() fire = false end) while fire do wait(0.1) fire() end
Of course this assumes that you have mouse
and fire()
defined somewhere.
To use your own code, OP, you're going to have to connect both the KeyDown and KeyUp events:
if (key == "f") then --[[in KeyDown]] if (not isFiring) and (not cloakActive.Value) and (not shieldActive.Value) and (speed.Value < fireSpeed) then isFiring = true while isFiring do fire() wait(weaponsCooldown) end end end if (key == "f") then --[[in KeyUp]] if (not isFiring) and (not cloakActive.Value) and (not shieldActive.Value) and (speed.Value < fireSpeed) then isFiring = false end end
This requires isFiring to be defined outside of either event, however, so that the same variable is accessible to both.