Character ignores Player - Door collision group

I have an NPC that uses pathfinding service, and since pathfinding service ignores collision groups, I’m having to do a bit of a nasty workaround.
Rather than setting the NPC - Door collision group to false, I’m having to set every part in the doors to CanCollide off, then add a collision group between the doors and the player’s character and set it to true.

Issue is, the player can still walk right through the door.
Knowing me I likely missed something or forgot to add an important line but I’m really stumped here.

Here’s the script I’m using, it runs when the server starts.
There are no errors in the dev console.

local doors = workspace:WaitForChild("Facility_Doors")

local GroupName = "Doors"
local LocalName = "Players"

PhysicsService:CreateCollisionGroup(GroupName)
PhysicsService:CreateCollisionGroup(LocalName)

PhysicsService:CollisionGroupSetCollidable(GroupName, LocalName, true)

for _,v in pairs(doors:GetDescendants()) do
	if v:IsA("BasePart") then
		v.CanCollide = false
		PhysicsService:SetPartCollisionGroup(v, GroupName)
	end
end
doors.DescendantAdded:Connect(function(v)
	if v:IsA("BasePart") then
		v.CanCollide = false
		PhysicsService:SetPartCollisionGroup(v, GroupName)
	end
end)

for _,v in pairs(Players:GetPlayers()) do
	if not v.Character then
		v.CharacterAdded:Wait()
	end
	
	for _,v in pairs(v.Character:GetDescendants()) do
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v, LocalName)
		end
	end
	v.Character.DescendantAdded:Connect(function(v)
		if v:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(v, LocalName)
		end
	end)
end
Players.PlayerAdded:Connect(function(v)
	v.CharacterAdded:Connect(function(c)
		for _,v in pairs(c:GetDescendants()) do
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v, LocalName)
			end
		end
		c.DescendantAdded:Connect(function(v)
			if v:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(v, LocalName)
			end
		end)
	end)
end)

Could all be avoided if PathfindingService respected collision groups, but here we are I guess.
Right now my explanation is that the CanCollide property is overriding the collision group.

You could maybe get away with raycasts in this scenario.
I believe raycasts do have regards toward CollisionGroups.

1 Like

Even using them I’m still unable to get the NPC to generate waypoints beyond doors unless the doors have their CanCollide property off, in which case the raycast ignores doors entirely.
Could potentially make the NPC teleport through doors if it detects one in the way but it really detracts from the feeling of being chased when it suddenly starts jittering while trying to recalculate its path afterwards.

I’ll keep experimenting and see if I can get anywhere with this.
I’m wondering now if humanoids don’t respect non-humanoid collision groups.

Was able to set door CanCollide property on server to false, and set it back to true on client.