path.Status returning NoPath after entering a room through a door it opened

Basically, I have a NPC that patrols around the house, then occasionaly chases players when on sight. The NPC can open doors by applying a tween on the door.

When chasing a player, the NPC can open a door, then enter the room. The problem is, upon entering the room, path.Status returns “NoPath” even tho it just passed through one ( through the door it opened ). The door is composed of unions but i also tried separating the unions into simple parts, which made no change.

TLDR: NPC’s pathfindingservice status yields “NoPath” after opening a door to a room then entering it, breaking the script.

Blockquote

local function walkTo(destination)
local path = getPath(destination)
if path.Status == Enum.PathStatus.NoPath then ----Temporary solution
print(“noPath”)
local target = findTarget()

	if target and target.Humanoid.Health > 0 then
		lastPos = target.HumanoidRootPart.Position
		attack(target)
	end
end

if path.Status == Enum.PathStatus.Success then  
	for i, waypoint in pairs(path:GetWaypoints()) do
		path.Blocked:Connect(function()
			print("Blocked")
			path:Destroy()
		end)
		if animPlaying == false then
			walkAnim:Play()
			animPlaying = true
		end

		attackAnim:Stop()

		local target = findTarget()

		if target and target.Humanoid.Health > 0 then
			lastPos = target.HumanoidRootPart.Position
			attack(target)
			break
		else
			if waypoint.Action == Enum.PathWaypointAction.Jump then
				humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			end

			if lastPos then
				humanoid:MoveTo(lastPos)
				humanoid.MoveToFinished:Wait()
				lastPos = nil
				break
			else
				humanoid:MoveTo(waypoint.Position)
				humanoid.MoveToFinished:Wait()
			end
		end
	end
else
	return
end

end

1 Like

Maybe the ceiling is too low? Have you tried enabling the navigation mesh visualizations (Studio Settings>General>Show Navigation Mesh) to see whether PathfindingService even thinks it is an accessible area?

Also, just to make sure, you have a PathfindingModifier on the door with PassThrough enabled, right?

1 Like

i wasn’t aware of pathmodifiers since it’s my first time using pathfindingservices so thank you for letting me know about it!

1 Like

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