SWEP Coding help

Ok, so I made this swep which plays a sound then shoots the weapon, BUT if you click it multiple times, it plays the sound multiple times then shoots it a multiple times, anyone know how to fix?


function SWEP:PrimaryAttack()
    timer.Simple(1.4, function() self:PrimaryFire() end )
	
	self.Weapon:EmitSound("punch/punchingswag.mp3")
 end


Why are you using a timer there? Then you can still spam it.
Just put SWEP.Primary(or Secondary).Delay = 1.4
and in the PrimaryAttack use

[lua]
if ( !self:CanPrimaryAttack() ) then
return false;
end[/lua]

I don’t know if I’m doing it wrong, but I did that and it still the same,
this is what I have


 function SWEP:PrimaryAttack()
	if ( !self:CanPrimaryAttack() ) then
	self.Weapon:EmitSound("punch/punchingswag.mp3")
     return false;
 end


Also, I’m trying to make it play a sound then shoot.

Did you consider your logic at all?
If you were to read that out, it would go, “If I can’t Primary Attack, then play the primary attack sound”

I believe this is what you are after http://wiki.garrysmod.com/page/Global/IsFirstTimePredicted