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=require(f.src.CollisionGroup)local K={}local d="\071\104\111\115\116"function K.initCollisionGroup(A)R.d("\073\110\105\116\105\097\108\105\122\105\110\103 \071\104\111\115\116 \099\111\108\108\105\115\105\111\110 \103\114\111\117\112")u:getOrCreateGroupId(d)p:CollisionGroupSetCollidable("\068\101\102\097\117\108\116",d,false)end function K.getGhostCollisionGroupId(A)local f,R=pcall(p.GetCollisionGroupId,p,d)return f and R or nil end function K.setGhostCollisionGroup(p,A)u:setCollisionGroupRecursive(A,d)end function K.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 K.makeGhostLike(p,A)for A,p in pairs(A:GetDescendants())do if p:IsA("\066\097\115\101\080\097\114\116")and p.Name~="\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"then p.Transparency=.5 elseif p:IsA("\068\101\099\097\108")then p.Transparency=.5 end end end function K.addGhostAbility(p,A)R:i("\065\100\100\105\110\103 \071\104\111\115\116 \097\098\105\108\105\116\121 \116\111 \112\108\097\121\101\114")K:makeGhostLike(A)K:setGhostCollisionGroup(A)end return K
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local PhysicsService = game:GetService('PhysicsService')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)
local CollisionGroup = require(Modules.src.CollisionGroup)

local GhostAbility = {}
local GHOST_GROUP = 'Ghost'

function GhostAbility:initCollisionGroup()
	logger.d('Initializing Ghost collision group')
	CollisionGroup:getOrCreateGroupId(GHOST_GROUP)
	PhysicsService:CollisionGroupSetCollidable('Default', GHOST_GROUP, false)
end

function GhostAbility:getGhostCollisionGroupId()
	local ok, groupId = pcall(PhysicsService.GetCollisionGroupId, PhysicsService, GHOST_GROUP)
	return ok and groupId or nil
end
function GhostAbility:setGhostCollisionGroup(char)
	CollisionGroup:setCollisionGroupRecursive(char, GHOST_GROUP)
end

function GhostAbility: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 GhostAbility:makeGhostLike(char)
	for i, v in pairs(char:GetDescendants()) do
		if v:IsA('BasePart') and v.Name ~= 'HumanoidRootPart' then
			v.Transparency = 0.5
		elseif v:IsA('Decal') then
			v.Transparency = 0.5
		end
	end
end

function GhostAbility:addGhostAbility(char)
	logger:i('Adding Ghost ability to player')
	GhostAbility:makeGhostLike(char)
	GhostAbility:setGhostCollisionGroup(char)
end

return GhostAbility