Hello there! I am faced with the task of making "PlayerCollisionGroup" collision group unable to push "NpcCollisionGroup"? I searched everywhere but didn't find an answer. Note that collision must be enabled. Here is my code, :
game:GetService("PhysicsService"):CreateCollisionGroup("PlayerCollisionGroup") game:GetService("PhysicsService"):CreateCollisionGroup("NpcCollisionGroup") for i, v in pairs(game.Workspace.NpcsOfBase63.NpcCarl) do if v:IsA("BasePart") then game:GetService("PhysicsService"):SetPartCollisionGroup(v, "NpcCollisionGroup") end end game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) for i, child in pairs(char:GetChildren()) do if child:IsA("BasePart") then game:GetService("PhysicsService"):SetPartCollisionGroup(child,"PlayerCollisionGroup") end end end) end)
game:GetService("PhysicsService"):CreateCollisionGroup("PlayerCollisionGroup") game:GetService("PhysicsService"):CreateCollisionGroup("NpcCollisionGroup") game:GetService("PhysicsService"):CollisionGroupSetCollidable("PlayerCollisionGroup", "NpcCollisionGroup", false) -- arguments 1 and 2 can be in any order -- false = not collidable
For better reliability you should add .DescendantAdded
event for when character is added and change collision group of parts passed through this event since some of his limbs might not be created yet when the :GetChildren
loop runs.