Swep Burst Fire

Hi, I’m making a swep using the cs base and have it to where they shoot 3 bullets but they get shoot all at once…I’m using a for loop to shoot the bullets here’s my primary function

function SWEP:PrimaryAttack()

self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )  
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )  
  
if ( !self:CanPrimaryAttack() ) then return end  
for i=1,3 do 
// Play shoot sound  
self.Weapon:EmitSound( self.Primary.Sound )  
  
// Shoot the bullet  
self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )  
  
// Remove 1 bullet from our clip  
self:TakePrimaryAmmo( 1 )  

if ( self.Owner:IsNPC() ) then return end  
  
// Punch the player's view  
self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )  
  
// In singleplayer this function doesn't get called on the client, so we use a networked float  
// to send the last shoot time. In multiplayer this is predicted clientside so we don't need to   
// send the float.  
end
if ( (SinglePlayer() && SERVER) || CLIENT ) then  
    self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )  
end  

end

[lua]
function SWEP:PrimaryAttack()

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

if ( !self:CanPrimaryAttack() ) then return end
for i=1,3 do
timer.Simple(i*shootDelay,function(self) --NEW LINE HERE
// Play shoot sound
self.Weapon:EmitSound( self.Primary.Sound )

// Shoot the bullet
self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )

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

if ( self.Owner:IsNPC() ) then return end

// Punch the player’s view
self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )

// In singleplayer this function doesn’t get called on the client, so we use a networked float
// to send the last shoot time. In multiplayer this is predicted clientside so we don’t need to
// send the float.
end,self) --…AND HERE
end
if ( (SinglePlayer() && SERVER) || CLIENT ) then
self.Weapon:SetNetworkedFloat( “LastShootTime”, CurTime() )
end

end
[/lua]