How can I make this not depricated

We are trying to make a tower defence game but this code is deprecated. How could we make it work?

	> **for i, object in ipairs(newTower:GetDescendants()) do**

** if object:IsA(“BasePart”) then**
** PhysicsService:SetPartCollisionGroup(object, “Tower”)**
** end**
** end**

1 Like
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:RegisterCollisionGroup("Tower")

for _, object in newTower:GetDescendants() do
	if object:IsA("BasePart") then
		--PhysicsService:SetPartCollisionGroup(object, "Tower")
		object.CollisionGroup = "Tower"
	end
end

BasePart.CollisionGroup = CollisionGroup