Need help with PathfindingModifiers (PassThrough)

Hey people so currently I’m trying to make a Pathfinding NPC that is able to walk through parts but not players and so I used PathfindingModifier and enabled PassThrough but for some reason it doesn’t walk to it, it gets stuck but somehow the NPC is able to know how to get to me, any help? (I AM USING A MODULE CALLED “SIMPLEPATH”)

Here is the code I’m using on the NPC

local SimplePath = require(script.SimplePath)

local Dummy = script.Parent

local Humanoid = script.Parent.Humanoid

local agentParams = {
	AgentRadius = 0,
	AgentHeight = Dummy:GetExtentsSize().Y,
	AgentCanJump = true,
	WayPointSpacing = math.huge,
	Costs = {
		Door = 0
	}
}

local AnimTrack


function findNearestTorso(pos)
	local list = game.Workspace:children()
	local torso = nil
	local dist = 100
	local temp = nil
	local human = nil
	local temp2 = nil
	local player = false
	for x = 1, #list do
		temp2 = list[x]
		if (temp2.className == "Model") and (temp2 ~= script.Parent) then
			temp = temp2:findFirstChild("HumanoidRootPart")
			human = temp2:findFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
				if game.Players:GetPlayerFromCharacter(temp2) and (temp.Position - pos).magnitude < dist then
					torso = temp
					dist = (temp.Position - pos).magnitude
					
				end
			end
		end
	end
	return torso
end

local Dummy = script.Parent
local Goal = Vector3.new()
local Path = SimplePath.new(Dummy, agentParams)

local target;

while true do
	wait(.25)
	local target = findNearestTorso(script.Parent.HumanoidRootPart.Position)
	if target then
	Goal = target.Position	
		Path:Run(Goal)	
	else
		
	end
end

Here is also a model which shows the error, feel free to check and tell me what is happening, because I have no clue: Test NPC with Map - Roblox

What is the door thing for? (Trying to help if you still remember this)

I totally forgot about this post! Yea so I wanted the door to only collide with the NPCS but not players and I thought PassThrough meant like NPCS can just ignore and collide with any part thats linked to it but realized it doesnt so I gave up and made a script that tweens the door open when a NPC touches it. Thanks for trying to help though!

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