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!