Delay in Auto-Matic Fire Mode?

I’ve been managing on making Pistols for a while now and I finally decided to work on my first Automatic.
My problem is unlike the semi weapons the automatics delay isn’t working I attempted using SWEP.Primary.Delay but for some reason no matter how high I set this number the weapon still fires 42 rounds in an equivalent of an second.
Could anyone tell me if this is the wrong command for an automatic and if yes perhaps give the me the code I am supposed to use instead.

Can we see the code in your SWEP.PrimaryAttack?

function SWEP:PrimaryAttack()

// Make sure we can shoot first
if ( !self:CanPrimaryAttack() ) then return end

// Play shoot sound

// Shoot 1 bullets, 20 damage, 0.02 aimcone
self:ShootBullet( 20, 1, 0.02 )

// Remove 1 bullet from our clip
self:TakePrimaryAmmo( 1 )

// Punch the player's view
self.Owner:ViewPunch( Angle( -1, 0, 0 ) )


This is the only thing I got under SWEP.PrimaryAttack
Is there anything I add onto this for an delay in between every shot in automatic?

[lua]function SWEP:CanPrimaryAttack()
if not self.LastFire then self.LastFire = CurTime() end
if self.LastFire > CurTime() then
return false
self.LastFire = CurTime() + self.PrimaryDelay
return true
return false

Try that.

Or you could put self:SetNextPrimaryAttack(CurTime()+self.Primary.Delay) at the end of your PrimaryAttack.

It worked thanks guys I made an mistake using it.

Once more thanks for the help :slight_smile: