attempt to call method 'GetWalkspeed' (a nil value)

As the title says, I have a weapon which increases your movespeed and is SUPPOSED to decrese it after a fixed time:


AddCSLuaFile()
SWEP.HoldType				= "normal"

SWEP.PrintName				= "Mutagen"
SWEP.Slot					= 11

SWEP.ViewModelFOV			= 10

SWEP.Base					= "weapon_tttbase"

SWEP.Kind					= WEAPON_CLASS
SWEP.WeaponID				= AMMO_PISTOL

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"
SWEP.Secondary.Sound       	= Sound("mutagen_sound.mp3")

SWEP.AutoSpawnable			= true

SWEP.ViewModel             	= "models/weapons/v_crowbar.mdl"
SWEP.WorldModel            	= "models/Items/combine_rifle_ammo01.mdl"
SWEP.NoSights              	= true

SWEP.AllowDrop				= false

function SWEP:PrimaryAttack()
	local ply = self.Owner
	if SERVER then
		ply:PS_Notify("Used Mutagen!")
		ply:SetWalkSpeed(ply:GetWalkSpeed()+200)
		ply:EmitSound(self.Secondary.Sound)
		self:Remove()
		timer.Simple(7,function()
			ply:SetWalkSpeed(ply:GetWalkspeed()-200)         --This is the problem causing line
		end)
	end
end

function SWEP:SecondaryAttack()
	self:PrimaryAttack()
end

function SWEP:Reload()
	self:PrimaryAttack()
end

function SWEP:Holster()
   return true
end

It gives you the movespeed but after the 7 seconds it just spits out this error:


[ERROR] gamemodes/terrortown/entities/weapons/mutagen.lua:42: attempt to call method 'GetWalkspeed' (a nil value)
  1. unknown - gamemodes/terrortown/entities/weapons/mutagen.lua:42

Timer Failed! [Simple][@gamemodes/terrortown/entities/weapons/mutagen.lua (line 41)]


…WHY o.O

Putting print(‘a’) into the timer works, so does that mean that GetWalkSpeed()/SetWalkSpeed() are not defined within a simpleTimer function?
If so, any ideas how I could fix that?

Or maybe im just blind and don’t see something obvious ._.

– Santifocus

it’s GetWalkSpeed not GetWalkspeed - case matters.

Well damn I actually was blind, I was sure i copied from the one above, tyvm