Trying to set a delay for my swep

So i am trying to make a delay on my swep to make a delay before you can use the EmitSound part of it. Idk how to delay it, idk if im suppose to use Curtime and if so idk how to use it. (Very new to lua)
And also if someone could tell me if i need to add ( SERVER ) to everything


 if ( SERVER ) then (Whatever) end 


	--Infomation/Needed
SWEP.Category = "DJ Kitty"
SWEP.Base = "weapon_base"
SWEP.PrintName	= "XXXTENTACION SWEP 2"
SWEP.Author = "DJ Kitty"
SWEP.Spawnable = true
SWEP.AdminSpawnable	= true
SWEP.Purpose = "Be Just Like XXXTENTACION"
SWEP.Contact = "Just find my steam profile Nerds"
SWEP.Instructions = "Play Some Loud Music."
SWEP.DrawCrosshair = false
SWEP.Secondary = false
	-- Swep Models / View
SWEP.ViewModel = "models/weapons/v_hands.mdl"
SWEP.WorldModel = "models/weapons/w_crowbar.mdl"
SWEP.ViewModelFOV = 50
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = true
SWEP.ViewModelFlip = false
SWEP.UseHands = false
SWEP.ViewModelBoneMods = {}
	-- Swep Primary Attack Settings
SWEP.Primary.ClipSize	= 0
SWEP.Primary.Automatic = false
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Ammo = "none"
SWEP.Primary.Delay = 0

-- HoldType
function SWEP:Initialize()
    self:SetWeaponHoldType("magic")
end

-- Primary
function SWEP:PrimaryAttack()
	self:EmitSound( "bratznugga.mp3" )
	RunConsoleCommand("act", ("halt")) 
	if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "XXXTENTACION - YuNg BrAtZ") end
end

-- Secondary
function SWEP:SecondaryAttack()
	self:EmitSound("sippinteafgt.mp3")
	RunConsoleCommand("act", ("halt")) 
	if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "XXXTENTACION - SippinTeaInYourHood") end
end

-- Reload
function SWEP:Reload()

 	if ( SERVER ) then self.Owner:Ignite("1") end
 	if ( SERVER ) then self.Owner:Kill() end
 	self:EmitSound( "fock.mp3" )
 	if ( SERVER ) then self.Owner:Say("Fock!") end -- Will make the player say "FOCK!" in chat
 	if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "FOCK!") end -- Will display infront of your screen saying "FOCK!"
 	if self.Owner:Alive() then RunConsoleCommand("kill") return end -- This added to make sure that the player dies! (Don't know how to use the IF, THEN, RETURN, So its prob broken but it works :/ )
end


-- Deploy
function SWEP:Deploy()
	self:EmitSound( "yuh.mp3" )
	if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "XXXTENTACION SWEP 2") end
end

function SWEP:Think()

end

I recommend you to check other sweps out there, there’s a function that adds a delay whenever you do a primary or secondary attack, part of learning is to find it by yourself, but as tip i recommend you to visit wiki.garrysmod.com and then search a function related to primaryattack and secondaryattack

well ive been using the wiki for mostly everything, i don’t see anything for delays. unless SWEP.Primary.Delay And that doesn’t work :/. And i also do look at the lua files of other swep’s, again cant find something for delay.

[editline]3rd August 2017[/editline]

Okay welp pretty sure i found it


self:SetNextPrimaryFire( CurTime() + 0.2 )

but not sure yet.

[editline]3rd August 2017[/editline]

Nope that didnt work for me

Actually that’s the function you have to use.
Keep sure to use it shared.
Not a if SERVER then or if CLIENT then-check.

To make sure using it shared, print yourself something after the function has run.
If it prints something in yellow and something in blue, you most likely did it right.

i still dont know how to make it work ;-;

We don’t know where are you using it or how are you using it, also 0.2 it’s too tony

okay so i found it out on how to use it!


function SWEP:SecondaryAttack()
	self:SetNextSecondaryFire(CurTime()+5)
	self:EmitSound("sippinteafgt.mp3")
	RunConsoleCommand("act", ("halt")) 
	if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "XXXTENTACION - SippinTeaInYourHood") end
end