Issue with collision groups

I have a part that I want the npc to collide with and the player to be able to go through it, but I’m not exactly sure if I’m using collision groups correctly or I have an issue because it is not working, does anyone know the issue?

Code:

local npc = game.Workspace.Spider

local ps = game:GetService("PhysicsService")

local safezoneGroup = script.Parent

ps:RegisterCollisionGroup("NPCGroup")
ps:RegisterCollisionGroup("SafezoneGroup")

ps:CollisionGroupSetCollidable("NPCGroup", "SafezoneGroup", true)

for i, v in npc:GetChildren() do
	if not v:IsA("BasePart") then continue end
	v.CollisionGroup = "NPCGroup"
end

safezoneGroup.CollisionGroup = "SafezoneGroup"
2 Likes

You forgot to make the default collision group and the safezone group not collidable

ps:CollisionGroupSetCollidable("Default", "SafezoneGroup", false)
2 Likes

Thank you, I’ve been trying to figure out a solution for so long

1 Like

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