I am working on a project were I need to change the collision group ID. I tried two ways in my scripts but neither are working please help.
game.Players.PlayerAdded:connect(function(player) local character = workspace:FindFirstChild(player.Name) for i,v in pairs(character:GetChildren()) do if v.ClassName == "MeshPart" then wait(.01) v.CollisionGroupId = 2 end end end)
and
game.Players.PlayerAdded:connect(function(player) for i,v in pairs(player.Character:GetChildren()) do if v.ClassName == "MeshPart" then wait(.01) v.CollisionGroupId = 2 end end end)
Here's an example what i use to remove Player Collision.
--Get the service local PS = game:GetService("PhysicsService") --Create group PS:CreateCollisionGroup("Characters") --Set collidability with eachother to false. PS:CollisionGroupSetCollidable("Characters","Characters",false) --PlayerAdded game.Players.PlayerAdded:Connect(function(Player) --CharacterAdded Player.CharacterAdded:Connect(function(Char) wait() -- roblox logic --Get all the parts in the character for _,v in pairs(Char:GetChildren()) do if v:IsA("BasePart") then --Add the part to the group so it doesnt collide with eachother. PS:SetPartCollisionGroup(v,"Characters") end end end) end)