So in my last post, I had a problem where my sword attack animations weren’t playing. I fixed that but now when I walk it won’t stop playing the animation. I’ve tried moving the code to different areas in the script and instead of using if statements i changed it to while loops but nothing is working! Any help?
spawn(function()
while wait() do
if script.Parent.Parent:FindFirstChildWhichIsA("Humanoid") then
local walkanim = script.Parent.Parent.Humanoid:LoadAnimation(walk)
local idleanim = script.Parent.Parent.Humanoid:LoadAnimation(idle)
while script.Parent.Parent.Humanoid.MoveDirection.Magnitude <= 0 do
wait()
idleanim:Play()
walkanim:Stop()
repeat wait() until script.Parent.Parent.Humanoid.MoveDirection.Magnitude > 0
if script.Parent.Parent.Humanoid.MoveDirection.Magnitude > 0 then break end
end
while script.Parent.Parent.Humanoid.MoveDirection.Magnitude > 0 do
wait()
idleanim:Stop()
walkanim:Play()
repeat wait() until script.Parent.Parent.Humanoid.MoveDirection.Magnitude <= 0
if script.Parent.Parent.Humanoid.MoveDirection.Magnitude <= 0 then break end
end
end
end
end)