Holding Animation Wont stop

  1. What do you want to achieve? I want to know why this is not working and how i can fix it

  2. What is the issue? The animation wont stop playing, i have already used :Stop() but it doesnt work

  3. What solutions have you tried so far? I have been trying with variables and stuff but nothing is working

This is currently in a normal script, i have also tried a local script:

local char = script.Parent.Parent
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")

local holdAnim = animator:LoadAnimation(script.Animation)

local holding = false

script.Parent.Equipped:Connect(function()
	holding = true
	
	if holding == true then
		holdAnim:Play()
	end
end)

script.Parent.Unequipped:Connect(function()
	holding = false
	holdAnim:Stop()
end)

If you want the animation to keep playing, it’s best to make the animation loop, then just play it and stop it whenever you need to. You should put this in a localscript. Try this:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")

local holdAnim = animator:LoadAnimation(script.Animation)
holdAnim.Looped = true

script.Parent.Equipped:Connect(function()
	holdAnim:Play()
end)

script.Parent.Unequipped:Connect(function()
	holdAnim:Stop()
end)

The animation is just player, but the problem is that it wont stop when i unequip the tool.

Perhaps try loading animation from Humanoid instead of Animator?

I have already tried that, but that also did not work

Try this approach:

tool.Equipped:Connect(function()
-- anim code here
    tool.Unequipped:Once(function()
         -- anim stop code here
    end)
end)

This also did not work, i tried some debugging with print() but it just says everything should work, i have no idea why the animation wont stop.