So, I’m working on my cruiser main guns and I have a variable known as “canShoot” and its by default enabled and disabled after the gun is shot, then re-enables right when the cooldown finishes.
local fire = game.ReplicatedStorage.FireGunEvent
game.ReplicatedStorage.FireGunEvent.OnServerEvent:Connect(function()
print("Checking if fire is valid...")
local canShoot = true
if canShoot == true then
canShoot = false
print("Valid")
local muzzle1 = script.Parent.Parent.Parent.Muzzle1
local muzzle2 = script.Parent.Parent.Parent.Muzzle2
local muzzle3 = script.Parent.Parent.Parent.Muzzle3
script.Parent.Parent.Fire:Play()
muzzle1.Emitter.Enabled = true
muzzle2.Emitter.Enabled = true
muzzle3.Emitter.Enabled = true
wait(0.5)
muzzle1.Emitter.Enabled = false
muzzle2.Emitter.Enabled = false
muzzle3.Emitter.Enabled = false
wait(7)
script.Parent.Parent.Reload:Play()
wait(3)
canShoot = true
end
end)
But it still lets you shoot even before the cooldown finishes.
If someone can figure this out I’d appreciate it.
Thanks,
– Luke