local A=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local p=game:GetService("\080\104\121\115\105\099\115\083\101\114\118\105\099\101")local f=A:WaitForChild("\077\111\100\117\108\101\115")local R=require(f.src.utils.Logger)local u={}function u.setCollisionGroupRecursive(R,A,f)if A:IsA("\066\097\115\101\080\097\114\116")then p:SetPartCollisionGroup(A,f)end for A,p in ipairs(A:GetChildren())do u:setCollisionGroupRecursive(p,f)end end function u.getOrCreateGroupId(f,A)local R,u=pcall(p.GetCollisionGroupId,p,A)if not R then R,u=pcall(p.CreateCollisionGroup,p,A)end return R and u or nil end return u
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local PhysicsService = game:GetService('PhysicsService')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)

local CollisionGroup = {}

function CollisionGroup:setCollisionGroupRecursive(object, groupName)
	if object:IsA('BasePart') then
		PhysicsService:SetPartCollisionGroup(object, groupName)
	end
	for _, child in ipairs(object:GetChildren()) do
		CollisionGroup:setCollisionGroupRecursive(child, groupName)
	end
end

function CollisionGroup:getOrCreateGroupId(name)
	local ok, groupId = pcall(PhysicsService.GetCollisionGroupId, PhysicsService, name)
	if not ok then
		-- Create may fail if we have hit the maximum of 32 different groups
		ok, groupId = pcall(PhysicsService.CreateCollisionGroup, PhysicsService, name)
	end
	return ok and groupId or nil
end

return CollisionGroup