Collision groups on team?

I’m trying to let 2 different teams of players to collide with each other but they’re not allowed to collide their own teammates.

I’m relatively new on using PhysicsService and I’ve read some of the threads about it, i’m wondering if there’s 10 teams, do I need 10 Collision groups? If so, do I create a Collision group upon a team is being added and set all player’s character’s BasePart to it and turn off the collisions on all other Team’s Collision group? How?

I would make a collision group, then do a “for i,v in pairs()” loop on the folder teams are being stored. Something like

--make collision group

for i,v in pairs(teams:GetChildren()) do
   --get player from team
   --add the player to the collision group

If you only need to worry about 2 teams, you can use the built in Collision Group Editor to make this easier for you. As an example:
image

if you want to do this via script, all you have to do is something like this:

for _,Team in ipairs(game.Teams:GetTeams()) do
	PhysicsService:CreateCollisionGroup(Team.Name)
	PhysicsService:CollisionGroupSetCollidable(Team.Name, Team.Name, false)
end

Then Player-wise just create a CharacterAdded event to set each descendant part of the Character to their corresponding team.

image
What does this mean? Shouldn’t it be a checked box such that Blue collides red?

Blue colliding Red is the same as Red colliding Blue so there is no reason to have a checkbox there since you can change that from the lower row.