TTT taser problem

I have problem wenn i try stop player from moving.
Player that uses stun gun gets error.
Error:
[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_tazer/shared.lua:165: attempt to call method ‘Lock’ (a nil value)

  1. tasePlayer - gamemodes/terrortown/entities/weapons/weapon_ttt_tazer/shared.lua:165 <- code on that line: tazedPlayer:Lock()
  2. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_tazer/shared.lua:89 <-call to function self:tasePlayer(tazedPlayer)

functions:



function SWEP:PrimaryAttack()

	local eyeTrace = self.Owner:GetEyeTrace()

    if !eyeTrace.Entity:IsPlayer() then
	    return
	end
	
	tazedPlayer = eyeTrace.Entity
	local dist = self.Owner:EyePos():Distance(tazedPlayer:GetPos())

    if dist > 300 then
        self.Owner:PrintMessage(HUD_PRINTCENTER, "Too Far Away!")
        return
	end
	
	if tazedPlayer.Tased == true then
        self.Owner:PrintMessage(HUD_PRINTCENTER, "You tase him allready!")
        return
	end
	
	if self.Owner.Tase == true then
        self.Owner:PrintMessage(HUD_PRINTCENTER, "Taser is in use")
        return
	end



    if tazedPlayer:IsPlayer() and dist < 301 and (self.Weapon:Clip1() != 0 ) then
	    self.Weapon:EmitSound("Weapon_StunStick.Activate")
		self.BaseClass.ShootEffects(self)

		oldModel = tazedPlayer:GetMaterial()
		tazedPlayer.Tased = true
		tazedPlayer.oldModel = oldModel
		self.Owner.Tase = true
		self:tasePlayer(tazedPlayer)
		
		self.ReloadTimer = CurTime() + self.ReloadTime
		self:TakePrimaryAmmo( 1 )
	end

end

function SWEP:tasePlayer(tazedPlayer)
	if IsValid(tazedPlayer) then
		local oldMat = tazedPlayer:GetMaterial()
		timer.Simple(self.TazedTime, function()
                                tazedPlayer:UnLock()
				tazedPlayer.frozen  = nill
				tazedPlayer:ConCommand("pp_motionblur 0")
				tazedPlayer:SetMaterial( oldMat )
				tazedPlayer.Tased = false		
				self.Owner.Tase = false
		end)
		tazedPlayer:Lock()
		tazedPlayer.frozen = true 
        tazedPlayer:ConCommand("pp_motionblur 1")
        self.Owner:ConCommand("pp_motionblur 0")
		tazedPlayer:PrintMessage(HUD_PRINTCENTER, "You got tazed bro.")
		tazedPlayer:SetMaterial( "models/alyx/emptool_glow" )
	end
end


Really, nobody knows? :confused:

@Edit: Despite what I said.
You are running a serverside function clientside.

Change the line:
[lua]self:tasePlayer(tazedPlayer)[/lua]
To look like this

[lua]if SERVER then
self:tasePlayer(tazedPlayer)
end[/lua]

Thanks!