Having trouble making the idle animation for a tool stop when moving

Hello!

So, for some quick context, I’m forwarding this post for my friend who’s a new developer, and doesn’t have posting permissions here yet. I tried my best to help him with my limited knowledge, but we came up with no solutions.

He successfully scripted a functioning idle animation for his tool, but he wants the animation to stop when the character is moving - which is the part that doesn’t work.

For some added technical context, this is a LocalScript inside a tool named “Fists” in the StarterPack.

local tool = script.Parent
local fistidle = Instance.new("Animation")
fistidle.AnimationId = "rbxassetid://14025916833" 
local players = game:GetService("Players")
local character = players.LocalPlayer.Character or players.LocalPlayer.CharacterAdded:Wait()
local walking = character:WaitForChild("Humanoid").MoveDirection.Magnitude
local track



tool.Equipped:Connect(function()
    track = script.Parent.Parent.Humanoid:LoadAnimation(fistidle)
    track.Priority = Enum.AnimationPriority.Action
    track.Looped = true
    track:Play()
end)



tool.Unequipped:Connect(function()
    if track then
        track:Stop()
    end
end)

tool.Equipped:Connect(function()
    if walking > 0 then 
        if track then
            track:Stop()
        end
    end
end)

Any and all help is appreciated. Thanks!

3 Likes

If it’s an idle animation, you should lower its priority to something below the waking animation. Then it will automatically stop.

1 Like

That was the first thing he tried, and it didn’t work. Thanks, though.