Hi so I am trying make a r6 pathfinding script that goes to a part but Im getting this error when I print out the path status and the npc does not move
Enum.PathStatus.NoPath
my script
local PFS = game:GetService("PathfindingService")
function showPath(path)
local waypoints = path:GetWaypoints()
for _, waypoint in ipairs(waypoints) do
local part = Instance.new("Part", game.Workspace)
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon
part.Anchored = true
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Position = waypoint.Position
game:GetService("Debris"):AddItem(part, 5)
end
end
function createPath(target)
print("WD")
local agentParams = {
AgentHeight = 2.5,
AgentRadius = 2,
AgentCanJump = true
}
print("AS")
local path = PFS:CreatePath(agentParams)
path:ComputeAsync(script.Parent.Torso.Position, game.Workspace.Part.Position)
print('ASWQW')
print(path.Status)
if path.Status == Enum.PathStatus.Success then
print("WDWDWDWWW")
local wayPoints = path:GetWaypoints()
print("WADWD")
return path, wayPoints
end
end
function main(target)
if target then
print("dsad")
local path, waypoints = createPath(target)
if path and waypoints then
print("WW")
for _, waypoint in ipairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump then
game.Workspace.NPC.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
script.Parent.Humanoid:MoveTo(waypoint.Position)
print("sadas")
script.Parent.Humanoid.MoveToFinished:Wait()
end
end
end
end
main(game.Workspace.Part)
Ignore the print statements those are just for debugging