Tool animation not stopping when unequipped

I want to stop my flashlight hold animation when I dont have the flashlight equipped but when I stop the animation it dosent stop

I am playing the animation every time tool.Activated is called

1 Like

Yeah so the issue is that you’re not stopping the animation on tool.Unequipped.
tool.Activated only fires when the player has the tool equipped and clicks.

Im stopping it in a local script

local player = game.Players.LocalPlayer

script.Parent.Unequipped:Connect(function()
	local holdAnimation = player.Character.Humanoid:LoadAnimation(script.Parent.Function.Hold)
	holdAnimation:Stop()
end)

Oh my god, no what you’re doing is something completely different.
What you’re doing here is not stopping the already existing animation, but you’re Loading a new one and then stopping the new one you’ve created.
Instead everything should be run in the same script, something like so:

local anim

local function activated()
   ...
   anim = ...:LoadAnimation()
   anim:Play()
end

local function unequipped()
   anim:Stop()
end

It should somewhat resemble this, make sure to connect both functions still.

1 Like

how do I get the humanoid from a server script nvm i figured it out

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.