Hello dear scriptinghelpers community! I just wrote some cool Code that lets an NPC find a path to me.
local ps = game:GetService("PathfindingService")
local toMove = workspace:WaitForChild("Zombie Doge")
local path = ps:ComputeRawPathAsync(toMove.HumanoidRootPart.Position,workspace.Sonnenroboter.HumanoidRootPart.Position,99999999999)
-- Get the path waypoints
local waypoints = path:GetWaypoints()
for i,waypoint in pairs(waypoints) do
toMove.Humanoid:MoveTo(waypoint.Position)
toMove.Humanoid.MoveToFinished:Wait()
if(waypoint.Action == Enum.PathWaypointAction.Jump)then
print("Jump!")
toMove.Humanoid.Jump = true
end
print("Done")
end
But I want that the NPC keeps going to the Player. Looping it of Course doesn't work how I want because it finishes the path and then makes a new.
How can I make it directly go to the Player?
