Problem with Weapon:GetActivity()

Here is the part of code of my SWEP:

function SWEP:Reload()
	local act = self.Weapon:GetActivity()
	if act = ACT_VM_IDLE_LOWERED then return end

	self.Idle = CurTime() + self.Owner:GetViewModel():SequenceDuration()

The idea of what I want to do is to make the Viewmodel play animation when weapon’s owner press Reload button and not to play if this is already playing.

However, when I press R, the “Something is creating script error” pop-ups and the animation isn’t even playing. Here what I get in console:

[ERROR] addons/csgo_knives_swep/lua/weapons/csgo_baseknife.lua:324: attempt to call method 'GetActivity' (a nil value)
  1. unknown - addons/csgo_knives_swep/lua/weapons/csgo_baseknife.lua:324

Hot to fix this?

local getseq = self:GetSequence()
local act = self:GetSequenceActivity(getseq)

if act == ACT_VM_IDLE_LOWERED then return end

self.Idle = CurTime() + self:SequenceDuration()

Try this

Thank you! It works now! :slight_smile: