Viewmodel animation loading Problem

Hello!
So I was making a AK47 and it seems to have a problem.


It occurs quite a often (about 60%) and it didnt load a equip animation and just stuck like there
What it should be:

Also when i when out to another tab and came back. It just go back to what it should be.

Is this a bug? or theres something wrong with my code? Please help!

Code:

run.RenderStepped:Connect(function(dt)
	update(gunmodel,dt,RecoilSpring,BobbleSpring,SwayingSpring)
	if equipcooldown == true then
		equipcooldown = false
		if (not lastequip == equip) then
			aim(false,gunmodel,weapon)
			lastequip = equip
			shooting = false
			if equip == true then
				RecoilSpring:shove(Vector3.new(-4,0,5))
				script.Equip:Play()
			gunmodel.Parent = game.Workspace.Camera
				equipanimation:Play()
				equipanimation:AdjustWeight(2)
				RecoilSpring:shove(Vector3.new(5,0,1))
			wait(equipanimation.Length)
			holdanimation:Play()
			elseif equip == false then
				aim(false,gunmodel,weapon)
				holdanimation:Stop()
				wait(holdanimation.Length)
				gunmodel.Parent = nil
		end
		print("Last equip is not same as this equip!")
		end
		equipcooldown = true
	end
end)