Setting the fire rate of a NPc weapon



function SWEP:CanPrimaryAttack()
	if self:GetNextPrimaryFire() > CurTime() then
		return false
	end

	if self:Clip1() < self.Primary.NumShots then
		return false
	end
	
	return true
end

function SWEP:PrimaryAttack()
	if !self:CanPrimaryAttack() then return end

	self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)

        --rest of code
end


This is the code for a npc weapon. I’m trying to set the fire rate.
This code is working so far, but the npc still tries to attack and makes the attack animation. How can I prevent this?

As far as I know, you can’t.

What about thoose wierd Revolvers that shoot missiles ^-^

I think its only possible for player version.
NPC will just rapid firing any Swep you gave to them

You have to make it yourself, there is no function that does that

Do you have an idea on how I could achieve that?

Yes I use it for my base, but the code is kind of long. Basically you need timers that run constantly, about every 0.1 seconds. Then you test and see if the SNPC is able to fire, and if it’s then make it fire. You can set delays between each fire using timers and just basic stuff like that bro