When you use moveto, the character in a straight line to the location you want it to go to. What if I want it to, for example, go around a rock that is in it's path during the process?
Also is there a way to change the rock's position according to an int value (1= 1 stud away from spawn) and change the character's path with it?
Use Pathfinding,
local TheFirst = script.Parent.TheNpc.Humanoid -- Change TheNpc to your npc's name local In = game.Workspace.FirstBrick -- Start Point local Out = game.Workspace.SecondBrick -- Finish Point local Click = game.Workspace.Click -- I clickable part to make him move local path = game:GetService("PathfindingService"):ComputeRawPathAsync(In.Position, Out.Position, 500) -- Don't ask me "Why 500?" I don't know. local points = path:GetPointCoordinates() Click.ClickDetector.MouseClick:connect(function() for _, point in pairs(points) do print("moving to: ", point) TheFirst:MoveTo(point) -- Don't try moving to the next point until we are close enough to the current point in the path repeat local distance = (point - TheFirst.Parent.Torso.Position).magnitude wait() until distance < 3 end end)
1) Change TheNpc to your npc's name 2) Make two bricks in the workspace , one called FirstBrick (Start point) and another one called SecondBrick (FinishPoint) 3)Make a brick in the workspace called Click, with a click detector inside. 4) Place the script in the workspace.
TIP: The npc will take the fastest way to the finish point.
If that doesn't work check: http://wiki.roblox.com/index.php?title=Pathfinding