Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I fix my NPC not moving with pathfinding?

Asked by 5 years ago

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.

01local PathfindingService = game:GetService("PathfindingService")
02 
03        local Enemies = game:GetService("ServerStorage"):WaitForChild("Enemies")
04 
05        local SpawnPoints = {workspace:WaitForChild("SpawnPoints").SP1,
06                      workspace:WaitForChild("SpawnPoints").SP2,
07                      workspace:WaitForChild("SpawnPoints").SP3}
08 
09        local EndPoints = {workspace:WaitForChild("EndPoints").EP1,
10                      workspace:WaitForChild("EndPoints").EP2,
11                      workspace:WaitForChild("EndPoints").EP3}
12 
13 
14        local ran = math.random(1,3)
15 
View all 28 lines...

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago
01local NPC = game.Workspace."npc name here"
02 
03while true do
04    wait()
05    NPC.Humanoid:MoveTo(game.Workspace."insert part name u want the npc to go".Position)
06    NPC.Humanoid.MoveToFinished:Wait()
07    wait("insert time here")
08    NPC.Humanoid:MoveTo(game.Workspace."insert part name u want the npc to go".Position)
09    NPC.Humanoid.MoveToFinished:Wait()
10    wait("instert time here")
11    NPC.Humanoid:MoveTo(game.Workspace."insert part name u want the npc to go".Position)
12    NPC.Humanoid.MoveToFinished:Wait()
13    wait("insert time here")
14end
0
Replace local spawn points and local end points and put this instead Shadic1270 136 — 5y
Ad

Answer this question