Path Service Help

  1. Keep it simple and clear!
    I want the Npc to jump when there is a wall and want the Npc to follow the part even if you position changes
  2. What is the issue?
    I don’t know how to make it work
  3. What solutions have you tried so far?
    I tried YouTube and DevForum.
local PathService = game:GetService("PathfindingService")
wait(3)
local Humanoid = script.Parent:WaitForChild("Humanoid")
local Torso = script.Parent:WaitForChild("HumanoidRootPart")

local Path = PathService:CreatePath()

	Path:ComputeAsync(Torso.Position, game.Workspace.FindPart.Position)


local Waypoints = Path:GetWaypoints()

for i, waypoint in pairs(Waypoints) do 
	if waypoint.Action == Enum.PathWaypointAction.Jump then
	 Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
	end
	Humanoid:MoveTo(waypoint.Position)
	wait()
	end

Not sure what exactly you’re asking. If you want to jump when the NPC hits something then you will want to create a way to set a MoveTo timeout. If the NPC timeouts before reaching the next waypoint (something is obstructing the path), re-compute path or skip a waypoint.

Alternatively, take a look at my pathfinding module. You can achieve that effect easily with just a few lines.

I want the npc to keep following the player or part even if it is moved and jump but I don’t know what you mean. I am new to scripting. I am trying to make a zombie game. So can you explani in detail with examples?

and also Thats a very cool module I will use it.

Sure. The SimplePath Devforum page has all the examples with scripts including an example place. My second example shows how to make the NPC constantly follow a part. Download the example place and paste the script for the second example in the script in ServerScriptStorage. From there, you can experiment with the script and observe how it works.

Where is the example place? @GrayzcaIe

SimplePath Example.rbxl
Here is the example place.

1 Like

hey @GrayzcaIe how do I find which humanoid to get the zombie to hunt?

Iterate over the number of characters and compare to see which character has the least vector magnitude between it and the zombie. Then just make the zombie follow that character.