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)