Pathfinding errors

I need help making a pathfinding script. I have some of it done and it wont work.

This is my script:
local pfs = game:GetService(“PathfindingService”)
local humanoid = script.Parent.Humanoid
local body = script.Parent:FindFirstChild(“Torso”)
local destination = game.Workspace:FindFirstChild(“Destination”).Position

local path = pfs:CreatePath()

path:ComputeAsync(body.Position, destination)

local waypoints = path:GetWaypoints()

for k, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoints.Position)

if waypoint.Action == Enum.PathWaypointAction.Jump then
	humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end

humanoid.MoveToFinished:Wait()

end

How do I fix this?

1 Like

I’m guessing you are having issues with getting your NPC to jump. You didn’t actually say what your problem was since “it won’t work” doesn’t tell us what is going on. A better description would be “my NPC won’t move” or “my NPC gets stuck” or “my NPC moves, then stops”.

Is it an R6 or R15 NPC? You look for local body = script.Parent:FindFirstChild(“Torso”) but there is no Torso in an R15 rig.

Another thing would be to mention if you get any errors in your Output window.

Here’s a good tutorial/intro to Pathfinding that includes AgentCanJump: Character Pathfinding | Roblox Creator Documentation

1 Like

it’s waypoint.Position, no ‘s’ in the waypoint

Please check your output. It is quite obvious you aren’t reading it. It’s a very useful tool.

2 Likes

it was that it didnt move chars