Answered by
6 years ago Edited 6 years ago
In the output, it says "Unable to cast Vector3 to Instance."
You're using the base part itself and not its position.
Sometimes I make this mistake too, but thanks to the output window, I'm able to fix it quickly on my own.
Here is the code you should use...
01 | local torso = script.Parent.Torso.Position |
02 | local base = game.Workspace.Base.Position |
03 | local human = script.Parent.Humanoid |
05 | local path = game:GetService( "PathfindingService" ):CreatePath() |
06 | path:ComputeAsync(torso,base) |
07 | local points = path:GetWaypoints() |
09 | for i,v in pairs (points) do |
10 | local p = Instance.new( "Part" ,workspace) |
13 | p.Size = Vector 3. new( "1,1,1" ) |
14 | p.CFrame = CFrame.new(v.Position) |
17 | if path.Status = = Enum.PathStatus.Success then |
18 | for i,v in pairs (points) do |
19 | human:MoveTo(v.Position) |
20 | human.MoveToFinished:Wait() |