Pathfinding Deprecation

I’m currently trying to learn pathfinding via a tutorial on Youtube(Devking one) and was wondering if this code is deprecated or something and what the alternative is, because the NPC doesn’t move at all

local pfs = game:GetService("PathfindingService")
local hum = script.Parent:WaitForChild("Humanoid")
local hrp  = script.Parent:WaitForChild("HumanoidRootPart")

local path = pfs:CreatePath()
path:ComputeAsync(hrp.Position,workspace.endpart.Position)
local waypoints = path:GetWaypoints()

for i,waypoint in ipairs(waypoints) do
	hum:MoveTo(waypoint.Position)
	hum.MoveToFinished:Wait()
end

hum:MoveTo(game.Workspace.endpart.Position)
2 Likes

Make sure the HumanoidRootPart is not Anchored, and the code is not deprecated at all, I think, but do this before getting the waypoints if path.Status == Enum.PathStatus.Success then and when you loop through

if waypoint.Action == Enum.PathWaypointAction.Jump then
    hum.Jump = true
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.