Why won't animation stop playing?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
  • I have a specific animation for a tool. The tool is only held differently, nothing more and nothing less.
  1. What is the issue?
  • Once the tool is unequipped/deactivated, the animation won’t stop playing. The character is stuck in that position. (Animation is set to Motion)
  1. What solutions have you tried so far?
  • Looked at other topics on the DevForum, and asked different developers in different servers.

Code:

local Tool = script.Parent.Parent

Tool.Equipped:Connect(function()
	local Animation = Tool.Animation
	local Character = Tool.Parent
	local Humanoid = Character.Humanoid
	local animator = Humanoid:FindFirstChildOfClass("Animator")

	local AnimationTrack = animator:LoadAnimation(Animation)
	AnimationTrack:Play()
	
	if Tool.Parent ~= Character then
		AnimationTrack:Stop()
	end
end)

Output:

1 Like

What is this section supposed to do? Is it once the character drops the tool, then it stops the anim? otherwise if they unequip, and it stays in their backpack, they still remain the parent of the tool and this “if then” wont ever become not equal.

1 Like

I just solved it. Switched the if Tool.Parent ~= Character then to Tool.Activated:Connect(function()

1 Like

But when activated, the tool releases like a ball/grenade and is thrown, should have included that, sorry!

1 Like