Why does my animations stop like this?

When I stop my animation when the tool is unequipped, this happens to my character. How can I fix this? I am in R15 character type soon as though bugs are happening with R6 right now.

My character is like frozen.

image

LocalScript:

Tool.Unequipped:Connect(function()
	local R15ToolEquipAnimation = R15Folder:WaitForChild("R15ToolEquip")
	local R6ToolEquipAnimation = R6Folder:WaitForChild("R6ToolEquip")

	local ToolEquipAnimation

	if Humanoid.RigType == Enum.HumanoidRigType.R15 then
		ToolEquipAnimation = Humanoid.Animator:LoadAnimation(R15ToolEquipAnimation)
	elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
		ToolEquipAnimation = Humanoid.Animator:LoadAnimation(R6ToolEquipAnimation)
	end

	coroutine.wrap(function()
		for _, AnimationTrack in pairs(Humanoid.Animator:GetPlayingAnimationTracks()) do
			if AnimationTrack.Name == "R15ToolIdle" or "R6ToolIdle" then
				AnimationTrack:Stop()
			end
		end
	end)()
end)

I don’t know if I’m missing something here, but why aren’t you just doing

ToolEquipAnimation:Stop()

Because for some reason when I use: ToolEquipAnimation:Stop() it doesn’t stop.

Wait, do you have another animation track for when the tool is equipped? If so, then I don’t think you’re supposed to make a brand new track for when it unequips.

Yes I do. This is the Equipped function. That’s all I’ve got:

Tool.Equipped:Connect(function()
	local R15ToolEquipAnimation = R15Folder:WaitForChild("R15ToolEquip")
	local R6ToolEquipAnimation = R6Folder:WaitForChild("R6ToolEquip")

	local ToolEquipAnimation

	if Humanoid.RigType == Enum.HumanoidRigType.R15 then
		ToolEquipAnimation = Humanoid.Animator:LoadAnimation(R15ToolEquipAnimation)
	elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
		ToolEquipAnimation = Humanoid.Animator:LoadAnimation(R6ToolEquipAnimation)
	end

	ToolEquipAnimation:Play()

	ToolEquipAnimation.Stopped:Connect(function()
		local R15ToolIdleAnimation = R15Folder:WaitForChild("R15ToolIdle")
		local R6ToolIdleAnimation = R6Folder:WaitForChild("R6ToolIdle")
		
		local ToolIdleAnimation

		if Humanoid.RigType == Enum.HumanoidRigType.R15 then
			ToolIdleAnimation = Humanoid.Animator:LoadAnimation(R15ToolIdleAnimation)
		elseif Humanoid.RigType == Enum.HumanoidRigType.R6 then
			ToolIdleAnimation = Humanoid.Animator:LoadAnimation(R6ToolIdleAnimation)
		end
		
		ToolIdleAnimation:Play()
	end)
end)

Try this. You’ve already loaded the same ToolEquipAnimation track so I don’t think you have to load it again.

Tool.Unequipped:Connect(function()
	coroutine.wrap(function()
		ToolEquipAnimation:Stop()
	end)()
end)

The animation isn’t stopping still.

Could be this if statement, you also need to do the name comparision to the R6 as well

if AnimationTrack.Name == "R15ToolIdle" or AnimationTrack.Name == "R6ToolIdle" then
2 Likes

Omg. I forgot about that. I am staring at my code and meanwhile forgetting about the mini errors. Thanks for the help.

1 Like
if string.match(AnimationTrack.Name, "ToolIdle$") then
	
end

If you prefer single operations.

1 Like