Collision Group select all children in a model with Instance.new

Hi there, I am trying to create a Collision Group in a model,but I don’t know how to do that, I don’t know how to add this in
local descendants = game.Workspace.Partsmodel:GetDescendants()
for index, descendant in pairs(descendants) do
– try to find a basepart inside the group into Collision Group
end
local PhysicsService = game:GetService(“PhysicsService”)
local groupNameA = “A”
local groupNameB = “B”

	PhysicsService:CreateCollisionGroup(groupNameA)
	PhysicsService:CreateCollisionGroup(groupNameB)

	PhysicsService:SetPartCollisionGroup(part, groupNameA)

– In here I don’t know how to do that
PhysicsService:SetPartCollisionGroup(workspace:WaitForChild(“Partsmodel”), groupNameB)

	PhysicsService:CollisionGroupSetCollidable(groupNameA, groupNameB, false)
local PhysicsService = game:GetService(“PhysicsService”)
local groupNameA = “A”
local groupNameB = “B”

PhysicsService:CreateCollisionGroup(groupNameA)
PhysicsService:CreateCollisionGroup(groupNameB)

PhysicsService:SetPartCollisionGroup(part, groupNameA)
PhysicsService:CollisionGroupSetCollidable(groupNameA, groupNameB, false)

local descendants = game.Workspace.Partsmodel:GetDescendants()
for index, descendant in pairs(descendants) do
    if descendant:IsA("BasePart") then
        PhysicsService:SetPartCollisionGroup(descendant, groupNameA)
    end
end

Simply set the part collision group inside the loop, and use :IsA() to check if its a part.

Thanks for that, I already know that while sloving this myself, I use:
Instance.new(“Part”,workspace.Partsmodel)
game.Debris:AddItem(part,20)

so that didn’t really works that well, I already wrote this where the instance.new(part) inside it while sloving this myself before you reply

local part = Instance.new(“Part”,workspace.Partsmodel)

part.Position = Vector3.new(23, 13.5, 25)

part.Name = “Part1”

local PhysicsService = game:GetService(“PhysicsService”)

local part1 = Instance.new(“Part”,workspace.Partsmodel)

part1.Position = Vector3.new(23, 0.5, 25)

part1.Name = “Part2”

local groupNameA = “A”

local groupNameB = “B”

PhysicsService:CreateCollisionGroup(groupNameA)

PhysicsService:CreateCollisionGroup(groupNameB)

PhysicsService:SetPartCollisionGroup(part, groupNameA)

PhysicsService:CollisionGroupSetCollidable(groupNameA, groupNameB, false)

PhysicsService:SetPartCollisionGroup(part, groupNameA)

local descendants = game.Workspace.Partsmodel:GetDescendants()

for index, descendant in pairs(descendants) do

if descendant:IsA(“BasePart”) then

PhysicsService:SetPartCollisionGroup(descendant, groupNameA)

end

end

it’s not working
This is just shows everytime it insert a new part, the parent of the part will be in the partsmodel group, but, not like part to part collision group