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