-- ================================================================================
-- LOCAL FUNCTIONS
-- ================================================================================

local function setModelAnchored(parent, anchored)
	for _, child in ipairs(parent:GetChildren()) do
		if (child:IsA("BasePart")) or (child:IsA("MeshPart")) then
			child.Anchored = anchored
		end
		setModelAnchored(child, anchored)
	end
end -- setModelAnchored()

local function setModelCanCollide(parent, canCollide)
	for _, child in ipairs(parent:GetChildren()) do
		if (child:IsA("BasePart")) or (child:IsA("MeshPart")) then
			child.CanCollide = canCollide
		end
		setModelAnchored(child, canCollide)
	end
end -- setModelCanCollide()

local function setModelTransparency(parent, transparency)
	for _, child in ipairs(parent:GetChildren()) do
		if (child:IsA("BasePart")) or (child:IsA("MeshPart")) then
			child.Transparency = transparency
		end
		setModelTransparency(child, transparency)
	end
end -- setModelTransparency()

local function removeLimbsAndThings(character)
	for _, child in ipairs(character:GetChildren()) do
		removeLimbsAndThings(child)
		if (not child:IsA("Humanoid")) and (not child:IsA("Motor6D")) 
			and (child.Name ~= "Head") and (child.Name ~= "UpperTorso") then
				child:Destroy()
		end
	end
end -- removeLimbsAndThings()

local function insertModelIntoCharacter(character, model)
	for _, child in ipairs(model:GetChildren()) do
		child.Parent = character
		insertModelIntoCharacter(child, child)
	end
end -- insertModelIntoCharacter()

local function setCollisionGroup(parent, group)
	for _,part in pairs(parent:GetChildren()) do
		if (part:IsA("BasePart") or (part:IsA("MeshPart"))) then
			PhysicsService:SetPartCollisionGroup(part, group)
		end
	end
end -- SetCollisionGroup()