How would I fix my NPC not moving with pathfinding?
I have this code that is supossed to spawn an enemy and then move them towards a brick in the workplace. The NPC spawns just fine but it does not move at all and just stands there. I also get no error in the output.
01 | local PathfindingService = game:GetService( "PathfindingService" ) |
03 | local Enemies = game:GetService( "ServerStorage" ):WaitForChild( "Enemies" ) |
05 | local SpawnPoints = { workspace:WaitForChild( "SpawnPoints" ).SP 1 , |
06 | workspace:WaitForChild( "SpawnPoints" ).SP 2 , |
07 | workspace:WaitForChild( "SpawnPoints" ).SP 3 } |
09 | local EndPoints = { workspace:WaitForChild( "EndPoints" ).EP 1 , |
10 | workspace:WaitForChild( "EndPoints" ).EP 2 , |
11 | workspace:WaitForChild( "EndPoints" ).EP 3 } |
14 | local ran = math.random( 1 , 3 ) |
16 | local RaiderClone = Enemies.Raider:Clone() |
17 | RaiderClone.Parent = workspace |
18 | RaiderClone.HumanoidRootPart.CFrame = SpawnPoints [ ran ] .CFrame |
20 | local path = PathfindingService:CreatePath() |
21 | path:ComputeAsync(RaiderClone.UpperTorso.Position,workspace.EndPoints.EP 1. Position) |
23 | local Waypoints = path:GetWaypoints() |
25 | for i,waypoint in pairs (Waypoints) do |
26 | RaiderClone.Humanoid:MoveTo(waypoint.Position) |
27 | RaiderClone.Humanoid.MoveToFinished:Wait( 2 ) |