local pathservice = game:GetService("PathfindingService") local path= pathservice:FindPathAsync(game.Workspace.Start.Position,game.Workspace.End.Position,512) local coord=path:GetWaypoints() wait() for i,v in pairs(coord) do wait() print ("executing "..i,v) game.Workspace.Robot.Humanoid:MoveTo(v) print("Moving to: ",v) game.Workspace.Robot.Humanoid.MoveToFinished:wait() end
Seems good to me...
Simple mistake. All you have to do is add .Position
next to v
, because v
is an Instance created part and you didn't tell the script to move to the position, just the part itself. That's what caused an error.
Fixed:
local pathservice = game:GetService("PathfindingService") local path= pathservice:FindPathAsync(game.Workspace.Start.Position,game.Workspace.End.Position,512) local coord = path:GetWaypoints() wait() for i,v in pairs(coord) do wait() print ("executing "..i,v) game.Workspace.Robot.Humanoid:MoveTo(v.Position) print("Moving to: ",v) game.Workspace.Robot.Humanoid.MoveToFinished:wait() end
You need to loop through the table constantly to continue updating the values and constantly moving to the next point in the table
Use a for loop for this.