I'm trying to code a Player-Player Collisions system. But Player and Player are still be able to collide each other Note: Im in Local Server Testing Mode
game.Players.PlayerAdded:Connect(function(plr) local PhysicsService = game:GetService("PhysicsService") local Character = plr.Character local PlayerCollisionGroup = PhysicsService:CreateCollisionGroup("Players") PhysicsService:CollisionGroupSetCollidable(PlayerCollisionGroup, PlayerCollisionGroup, false) for index, value in pairs(Character:GetDescendants()) do if value:IsA("BasePart") then value.CollisionGroupId = PhysicsService:GetCollisionGroupId("Players") end end end)
game:GetService("Players").PlayerAdded:Connect(function(plr) local PhysicsService = game:GetService("PhysicsService") local Character = plr.Character local PlayerCollisionGroup local success,fail = pcall(function() PlayerCollisionGroup = PhysicsService:GetCollisionGroupId("Players") end) if fail then PlayerCollisionGroup = PhysicsService:CreateCollisionGroup("Players") PhysicsService:CollisionGroupSetCollidable("Players","Players",false) end for index, value in pairs(Character:GetDescendants()) do if value:IsA("BasePart") then PhysicsService:SetPartCollisionGroup(value,"Players") end end plr.CharacterAdded:Connect(function() wait(1/30) Character = plr.Character for index, value in pairs(Character:GetDescendants()) do if value:IsA("BasePart") then PhysicsService:SetPartCollisionGroup(value,"Players") end end end) end)