Hello, I’m trying to make the player walk through npc’s by changing the collsion group. When changing the group of the npc all part’s in the model change groups. When doing the same for the player only the Head and HumanoidRootPart change groups. When manualy clicking the + on the PlayerGroup when selecting my character the collisions work, so anyone know’s how I can change al part’s collisions using scripts ?
What the script does:
What I need it to do:
local PhysicsService = game:GetService("PhysicsService")
local defaultGroup = PhysicsService:GetCollisionGroupName(0)
local playerGroup = "PlayerGroup"
local npcGroup = "NPCGroup"
PhysicsService:CreateCollisionGroup(playerGroup)
PhysicsService:CreateCollisionGroup(npcGroup)
function game.ReplicatedStorage.Events.SetPhysics.OnInvoke(Type, char)
if(Type == "npc") then
for i,v in pairs(char:GetDescendants()) do
if (v:IsA("BasePart")) then
PhysicsService:SetPartCollisionGroup(v, npcGroup)
end
end
else
for i,v in pairs(char:GetDescendants()) do
if (v:IsA("BasePart")) then
PhysicsService:SetPartCollisionGroup(v, playerGroup)
end
end
end
end
PhysicsService:CollisionGroupSetCollidable(playerGroup, npcGroup, false);
PhysicsService:CollisionGroupSetCollidable(playerGroup, playerGroup, true);
PhysicsService:CollisionGroupSetCollidable(npcGroup, npcGroup, false);
PhysicsService:CollisionGroupSetCollidable(playerGroup, defaultGroup, true);
PhysicsService:CollisionGroupSetCollidable(npcGroup, defaultGroup, true);