-- Given a part, will return return the character from the given part.

function PartUtility.GetCharacterFromInstance_R(part)
	local model = part:FindFirstAncestorOfClass("Model")
	if model and model:FindFirstChild("Humanoid") then
		return model
	elseif model then
		PartUtility.GetCharacterFromInstance_R(model)
	end
end

function PartUtility.MakeInvisible(model)
	for _, child in pairs(model:GetDescendants()) do
		if child:IsA("BasePart") then
			child:SetAttribute("InitialTransparency",child.Transparency)
			child.Transparency = 1
		end
	end
end

function PartUtility.RestoreVisibility(model)
	for _, child in pairs(model:GetDescendants()) do
		if child:IsA("BasePart") then
			child.Transparency = child:GetAttribute("InitialTransparency") and child:GetAttribute("InitialTransparency") or 0
		end
	end
end

function PartUtility.MakeVisible(model)
	for _, child in pairs(model:GetDescendants()) do
		if child:IsA("BasePart") then
			child.Transparency = 0
		end
	end
end

return PartUtility
