Animation playing issue

Hello there!

I am working on an animation for a sword idle, however the animation only plays once, and then stops. I added a while true loop when the tool is equipped, however it keeps playing after I unequip it.

My code:

local Tool = script.Parent

local Player = game.Players.LocalPlayer

local Char = game.Workspace:WaitForChild(Player.Name)

local Humanoid = Char:WaitForChild("Humanoid")

local Idle = Humanoid:LoadAnimation(script:WaitForChild("Idle", 100))

Tool.Equipped:Connect(function()

while true do

wait(0.7)

Idle:Play()

end

end)

Tool.Unequipped:Connect(function()

Idle:Stop()

end)

(Apologize if the code isn’t exactly indented properly)

I want to know how to fix this, as it was copied from another post here: Stop playing Idle Animation

The code has worked before but now it is not working as intended. Any help is appreciated!

When you exported the animation, Did you checked/marked the loop option? If you didn’t, This may be the reason of why it isn’t looping.

Loop

It works now, thanks! I didn’t even know that was an option in the animator. I’m still new to it. Thanks anyways!

1 Like