How do I create collision groups for both a player and an NPC?

Hello, I want to make a system where you cannot touch an NPC as a player. I put the same script in both the NPC and the player, although it does not seem to work. To make sure the collision worked for other objects, I put the script into the workspace, and it worked for anything that was a part. If you have any suggestions, please discuss them here. Thanks!

The script used in both the player and NPC:


wait()
for i,v in pairs(script.Parent:GetDescendants()) do
	if v:IsA("Part") then
		v.CollisionGroup = "NoCollisionsGroup"
	end
end

The physics group:

local physics = game:GetService("PhysicsService"):RegisterCollisionGroup("NoCollisionsGroup")
game:GetService("PhysicsService"):CollisionGroupSetCollidable("NoCollisionsGroup", "NoCollisionsGroup", false)

Solution: Change the Avatar type to r6 instead of r15.

1 Like

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