Collision groups not working

i have npcs that are in a collision group (named XMonsterNPCS) and i have parts that are in a collision group (PathModifiers) and im trying to make it so the NPCs can go through the parts.
however, the NPCs arent able to go through the parts

the PathModifiers collision group parts are meant to change how the NPC computes its path while the npc can still go through it.
this is my collision group layout:
image

this may not be needed, but this is a script im using:

local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")

local NPCS = workspace:WaitForChild("Animation")

PhysicsService:CreateCollisionGroup("Characters")
PhysicsService:CreateCollisionGroup("NPC")
PhysicsService:CreateCollisionGroup("NPC1")
PhysicsService:CreateCollisionGroup("NPCs")
PhysicsService:CollisionGroupSetCollidable("Characters", "Characters", false)
PhysicsService:CollisionGroupSetCollidable("Characters", "NPC", false)
PhysicsService:CollisionGroupSetCollidable("Characters", "NPC1", false)
PhysicsService:CollisionGroupSetCollidable("NPCs", "Characters", false)




local function onDescendantAdded(descendant)
	-- Set collision group for any part descendant
	if descendant:IsA("BasePart") then
		PhysicsService:SetPartCollisionGroup(descendant, "Characters")

	end
end

for i, v in pairs(NPCS:GetDescendants()) do
	if v:IsA("BasePart") then
		PhysicsService:SetPartCollisionGroup(v, "NPC")
		PhysicsService:SetPartCollisionGroup(v, "NPC1")
		PhysicsService:SetPartCollisionGroup(v, "NPCs")
	end
end

local function onCharacterAdded(character)
	-- Process existing and new descendants for physics setup
	for _, descendant in pairs(character:GetDescendants()) do
		onDescendantAdded(descendant)
	end
	character.DescendantAdded:Connect(onDescendantAdded)
end

Players.PlayerAdded:Connect(function(player)
	-- Detect when the player's character is added
	player.CharacterAdded:Connect(onCharacterAdded)
end)

yes i know its really messy

1 Like

if you are using the pathmodifier object, don’t need to worry about collisions, if they have no collisions, players can walk through, while (depending on the cost set) anything using pathfinding (monsters in your case) won’t go through.

im not using any pathmodifiers objects. im using parts in a folder which are connected to a collision grouped named “PathModifiers” and another folder which contains all the NPCs which has a collision grouped connected to it named “XMonsterNPCS”

players can walk through the parts, but for some reason NPCs cant.

why not use the path finder objects themselves? They are better than using collision groups

I could, but I’m trying to modify how the NPC thinks to get to a path.
Let me elaborate:
this is what happens without the parts

now when i add the parts you can see it thinks differently and tries to go even further around it. CanCollide is on so the pathfinding thinks to go around it, but im trying to use collision groups that way the object has CanCollide off, but the pathfinding still thinks CanCollide is on. The problem is that the Collision Group doesnt work and the NPC can still collide with the part, when it shouldnt.

on the side, when I use a pathfinding modifier and set the part to CanCollide = true but the pathfinding modifier to PassThrough = true, the NPC cannot pass through it.

put the cost higher, pathfinding will try to avoid it the higher it is

the cost is literally math.huge,