I'm trying to make npcs walk to parts, which works, but when I try to play the animation it doesn't work, does anyone have a fix?
while wait(0.25) do script.Parent:MoveTo(game.Workspace.Path.Part3.Position) script.Parent.MoveToFinished:Wait() script.Parent:MoveTo(game.Workspace.Path.Part1.Position) script.Parent.MoveToFinished:Wait() script.Parent:MoveTo(game.Workspace.Path.Part4.Position) script.Parent.MoveToFinished:Wait() script.Parent:MoveTo(game.Workspace.Path.Part2.Position) end local anim = script.Parent:LoadAnimation(script.Parent.Animation) anim:Play()
ANSWER: You put your while loop first so any code outside of the while loop will not run until the while loop has finished. (And your while loop never ends, therefore you never get to line 11 and 12.
FIX:
local anim = script.Parent:LoadAnimation(script.Parent.Animation) anim:Play() while wait(0.25) do script.Parent:MoveTo(game.Workspace.Path.Part3.Position) script.Parent.MoveToFinished:Wait() script.Parent:MoveTo(game.Workspace.Path.Part1.Position) script.Parent.MoveToFinished:Wait() script.Parent:MoveTo(game.Workspace.Path.Part4.Position) script.Parent.MoveToFinished:Wait() script.Parent:MoveTo(game.Workspace.Path.Part2.Position) end