local M=instance("\067\097\109\101\114\097")local v={MeshPart=true,Part=true;Accoutrement=true;Pants=true,Shirt=true,Humanoid=true,UnionOperation=true}local function s(M,s,k)local N=M:GetDescendants()for M=1,#N,1 do local k=N[M]if v[k.ClassName]then local M=k.Archivable k.Archivable=true local v=k:Clone()k.Archivable=M if v.ClassName=="\080\097\114\116"or v.ClassName=="\077\101\115\104\080\097\114\116"then v.CanCollide=false end if k.ClassName=="\077\101\115\104\080\097\114\116"or k.ClassName=="\080\097\114\116"then PartUpdater=RunService.Heartbeat:Connect(function()if k then v.CFrame=k.CFrame else v:Destroy()PartUpdater:Disconnect()end end)elseif k:IsA("\065\099\099\111\117\116\114\101\109\101\110\116")then PartUpdater=RunService.Heartbeat:Connect(function()if k then if v.Handle then v.Handle.CFrame=k.Handle.CFrame end else v:Destroy()PartUpdater:Disconnect()end end)elseif k.ClassName=="\072\117\109\097\110\111\105\100"then v:SetStateEnabled(Enum.HumanoidStateType.FallingDown,false)v:SetStateEnabled(Enum.HumanoidStateType.Running,false)v:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics,false)v:SetStateEnabled(Enum.HumanoidStateType.Climbing,false)v:SetStateEnabled(Enum.HumanoidStateType.StrafingNoPhysics,false)v:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,false)v:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)v:SetStateEnabled(Enum.HumanoidStateType.Jumping,false)v:SetStateEnabled(Enum.HumanoidStateType.Landed,false)v:SetStateEnabled(Enum.HumanoidStateType.Flying,false)v:SetStateEnabled(Enum.HumanoidStateType.Freefall,false)v:SetStateEnabled(Enum.HumanoidStateType.Seated,false)v:SetStateEnabled(Enum.HumanoidStateType.PlatformStanding,false)v:SetStateEnabled(Enum.HumanoidStateType.Dead,false)v:SetStateEnabled(Enum.HumanoidStateType.Swimming,false)v:SetStateEnabled(Enum.HumanoidStateType.Physics,false)end v.Parent=s end end end

local Camera = instance("Camera")

local ValidClasses = {
	["MeshPart"] = true; ["Part"] = true; ["Accoutrement"] = true;
	["Pants"] = true; ["Shirt"] = true;
	["Humanoid"] = true; ["UnionOperation"] = true;
}

local function RenderHumanoid(Model, Parent, MainModel)
	local ModelParts = Model:GetDescendants()
	for i=1, #ModelParts do
		local Part		= ModelParts[i]
		
		if ValidClasses[Part.ClassName] then

			local a			= Part.Archivable
				Part.Archivable	= true
				
			local RenderClone	= Part:Clone()
				Part.Archivable	= a

			if (RenderClone.ClassName == "Part" or RenderClone.ClassName == "MeshPart") then
				RenderClone.CanCollide = false;
				--RenderClone.Anchored = true;
			end
		
			if Part.ClassName == "MeshPart" or Part.ClassName == "Part" then
				PartUpdater = RunService.Heartbeat:Connect(function()
					if Part then
						RenderClone.CFrame = Part.CFrame
					else
						RenderClone:Destroy()
						PartUpdater:Disconnect()
					end
				end)
			elseif Part:IsA("Accoutrement") then
				PartUpdater = RunService.Heartbeat:Connect(function()
					if Part then
						if RenderClone.Handle then
							RenderClone.Handle.CFrame = Part.Handle.CFrame
						end
					else
						RenderClone:Destroy()
						PartUpdater:Disconnect()
					end
				end)
			elseif Part.ClassName == "Humanoid" then
				--Disable all states. We only want it for clothing wrapping, not for stupid @$$ performance issues
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.FallingDown,			false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Running,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics,	false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Climbing,			false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.StrafingNoPhysics,	false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.GettingUp,			false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Jumping,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Landed,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Flying,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Freefall,			false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Seated,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.PlatformStanding,	false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Dead,				false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Swimming,			false)
				RenderClone:SetStateEnabled(Enum.HumanoidStateType.Physics,				false)
			end
			
			RenderClone.Parent = Parent
		end 
	end
end

