Set players armour via swep

Just a quick question to anyone willing to help.
How would i go abouts setting a players armour in terms of using a swep.
Somthing along the terms of: “:SetArmor(self.Owner, 100 )”?
Thankyou for your time.

Console returns this error when mouse1 is pressed:

weapons/test/shared.lua:107: attempt to call method ‘SetArmor’ (a nil value)

How i used it:

function SWEP:PrimaryAttack()
player:SetArmor( 1 )

function SWEP:PrimaryAttack()

Because the swep is the weapon not the player.

self being the wep
self.Owner being the person holding the weapon.

What about setting player speed?
i get this error:

weapons/cloaking/shared.lua:108: attempt to call method ‘SetPlayerSpeed’ (a nil value)

with this code:

self.Owner:SetPlayerSpeed(3000, 9000)

Any idea’s on this?

Because functions aren’t methods.

You’re looking for “SetWalkSpeed” or “SetRunSpeed”

Thanks for your help!
One more question while i’m at it.

when i use “self.Weapon:EmitSound” on say, a weapon function, it spams the sound while the button is down. how do i stop that?

Garry solves this using a code to the effect if the key pressed is ON-USE then return end, sorry I don’t know It offhand but I’m on a phone atm.

Care to expand anyone?

[lua]if( self.NextSound > CurTime() ) then
self.NextSound = CurTime() + 5

Thanks, how would i incorporate it for an entire swep function?
would it be along the lines of:

function SWEP:PrimaryAttack()
if( SWEP:PrimaryAttack > CurTime() ) then
    SWEP:PrimaryAttack = CurTime() + 5

function SWEP:PrimaryAttack()
if( self.PrimaryAttack > CurTime() ) then
self.PrimaryAttack = CurTime() + 5

self = SWEP when inside a function.