SWEP reloading animation interruptions

A note before you read this and get super triggered by my stupidity/lack of knowledge, I’m very very much a noob at this stuff.
Hello, I am having some frustrating problems with my reload animation working properly in my SWEP. It works, actually works great, however the problem occurs because of the fact that I have set an animation to be played while I sprint.
cough don’t murder me for what you’re about to see, I had to improvise for sprint animation since I can’t animate. I know, it’s awful. By the way this is inside of the ‘SWEP:Think’ function.


if self.Owner:KeyPressed(IN_SPEED) then
		self.Weapon:SendWeaponAnim( ACT_VM_HOLSTER )
	end
	if self.Owner:KeyReleased(IN_SPEED) then
		self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
	end

Now, as a result of this the reload animation becomes interrupted when either initiating sprint during the reload animation, or ending the sprint due to the other animations being played.

What I’ve tried as a solution is to try using something to trigger a ‘if -whatever- then return end’ on the keypressed if the reload is happening.
Unfortunately I can’t find any way of checking if the weapon is reloading. I had tried to set a variable to 1 at the start of the reload, and back to 0 at the end, and run the ‘if then return end’ off of that value, but I think I either did it wrong or it doesn’t work like that.

Below is also the contents of the reload function.


function SWEP:Reload()
	if ( self.Weapon:Clip1() >= 30 ) then return end
	if self.ReloadingTime and CurTime() <= self.ReloadingTime then return end
	
	self:SetIronsights( false )

	if ( self.Weapon:Clip1() <= 0 ) then
	self.Weapon:DefaultReload( ACT_VM_RELOAD_EMPTY )
	local AnimationTime = self.Owner:GetViewModel():SequenceDuration()
	self.ReloadingTime = CurTime() + AnimationTime
	else
	self.Weapon:DefaultReload( ACT_VM_RELOAD )
	local AnimationTime = self.Owner:GetViewModel():SequenceDuration()
	self.ReloadingTime = CurTime() + AnimationTime
	end
end