Attempt to index nil with 'IsPlaying'

Im trying to prevent animations from playing once the tool has been put away. It’s an annoying glitch. I’ve tried using .IsPlaying to detect if the animation track is being used. Not sure what I’m doing wrong.

tool.Unequipped:Connect(function()
	mouse.Icon = 'rbxasset://SystemCursors/Arrow'
	caninteract = false
	game.ReplicatedStorage.ScotEvents.ConnectM6D:FireServer(tool.BodyAttach)
	Equip:Stop()
	Idle:Stop()
	canfire = false
	aimed = false
	
	if Equip.IsPlaying then
		Equip:Stop()
	end
	if Idle.IsPlaying then
		Idle:Stop()
	end
	if Reload.IsPlaying then
		Reload:Stop()
	end
	if Aim.IsPlaying then
		Aim:Stop()
	end
	if AimIdle.IsPlaying then
		AimIdle:Stop()
	end
	if Bolt.IsPlaying then
		Bolt:Stop()
	end
	if Fire.IsPlaying then
		Fire:Stop()
	end
	
end)

put this in, should fix it…

if Equip.IsPlaying then
		Equip:Stop()
else return

	end
	if Idle.IsPlaying then
		Idle:Stop()
else return

	end
	if Reload.IsPlaying then
		Reload:Stop()
else return

	end
	if Aim.IsPlaying then
		Aim:Stop()
else return
	end
	if AimIdle.IsPlaying then
		AimIdle:Stop()
else return

	end
	if Bolt.IsPlaying then
		Bolt:Stop()
else return

	end
	if Fire.IsPlaying then
		Fire:Stop()
else return

	end

The error is gone, but the animation glitch is still accuring… :thinking:

image