Been trying to fix this all day

Well, so i got this problem with a swep I’m making. When i press MOUSE1, it attacks twice. I’ve been trying to figure out why it’s happening, but nothing seems to have worked.

Primary Attack code:

Try this out. **[Weapon.SetNextPrimaryFire

http://wiki.garrysmod.com/favicon.ico](http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index19b5.html)**

Thanks bunch for helping, but sadly it does not seem to have an effect.

Are you making sure to check if you can shoot before you can shoot, then setting the delay?

This is from the tutorial explosion swep


function SWEP:PrimaryAttack()
 
	-- if our weapon cannot primary attack due to SetNextPrimaryFire, then return end
	if ( !self:CanPrimaryAttack() ) then return end
 
	--Do all the primary shooting stuff

        -- Set the next primary fire. This works in conjunction with " if ( !self:CanPrimaryAttack() ) then return end "
	self:SetNextPrimaryFire( CurTime() + self.Delay )

end


Thanks a bunch, this did the trick. I’ve also encountered another problem now. I’ve made this code that when i right click, it check’s for both NPCs or players in a radius of 80, and then deals 1 damage to them. It works… It deals the 1 damage, but i keep getting this error spammed: [ERROR] lua/weapons/pred_epicgun/shared.lua:305: attempt to call method ‘TakeDamage’ (a nil value)

  1. unknown - lua/weapons/pred_epicgun/shared.lua:305

At the start of the function

[LUA]
if not IsFirstTimePredicted () then return end
[/LUA]

That’s it. Thanks a bunch. People are so helpful.