-- Decompiled with the Synapse X Luau decompiler.


local l__Players__1 = game:GetService("Players");
return function(p1, p2, p3)
	local v1 = l__Players__1:GetUserIdFromNameAsync(p1);
	p1 = l__Players__1:GetNameFromUserIdAsync(v1);
	local v2 = l__Players__1:GetCharacterAppearanceAsync(v1);
	if p3 == nil then
		if v2.IsR15.Value then
			local v3 = "R15";
		else
			v3 = "R6";
		end;
		local v4 = script[v3]:Clone();
		if not v4 then
			if p3 then
				local v5 = "R15";
			else
				v5 = "R6";
			end;
			v4 = script[v5]:Clone();
		end;
	else
		if p3 then
			v5 = "R15";
		else
			v5 = "R6";
		end;
		v4 = script[v5]:Clone();
	end;
	local l__Head__6 = v4.Head;
	local l__Humanoid__7 = v4.Humanoid;
	p3 = v4.Name == "R15";
	local l__next__8 = next;
	local v9, v10 = v2:GetChildren();
	while true do
		local v11, v12 = l__next__8(v9, v10);
		if not v11 then
			break;
		end;
		v10 = v11;
		if v12:IsA("Accessory") then
			l__Humanoid__7:AddAccessory(v12);
		end;	
	end;
	local l__next__13 = next;
	local v14, v15 = v2:GetChildren();
	while true do
		local v16, v17 = l__next__13(v14, v15);
		if not v16 then
			break;
		end;
		v15 = v16;
		if v17:IsA("ValueBase") and p3 then
			v17.Parent = l__Humanoid__7;
		end;	
	end;
	local l__next__18 = next;
	local v19, v20 = v2:GetChildren();
	while true do
		local v21 = nil;
		local v22 = nil;
		v22, v21 = l__next__18(v19, v20);
		if not v22 then
			break;
		end;
		v20 = v22;
		if p3 then
			if v21.Name == "R15ArtistIntent" then
				local l__next__23 = next;
				local v24, v25 = v21:GetChildren();
				while true do
					local v26, v27 = l__next__23(v24, v25);
					if not v26 then
						break;
					end;
					v25 = v26;
					l__Humanoid__7:ReplaceBodyPartR15(Enum.BodyPartR15[v27.Name], v27);				
				end;
			end;
		elseif v21.Name == "R6" then
			v21:GetChildren()[1].Parent = v4;
		end;	
	end;
	local l__Body_Colors__28 = v2:FindFirstChild("Body Colors");
	if l__Body_Colors__28 then
		l__Body_Colors__28.Parent = v4;
	end;
	local l__Shirt__29 = v2:FindFirstChild("Shirt");
	if l__Shirt__29 then
		l__Shirt__29.Parent = v4;
	end;
	local l__Shirt_Graphic__30 = v2:FindFirstChild("Shirt Graphic");
	if l__Shirt_Graphic__30 then
		l__Shirt_Graphic__30.Parent = v4;
	end;
	local l__Pants__31 = v2:FindFirstChild("Pants");
	if l__Pants__31 then
		l__Pants__31.Parent = v4;
	end;
	local l__Mesh__32 = v2:FindFirstChild("Mesh");
	if l__Mesh__32 then
		l__Head__6.Mesh:Destroy();
		l__Mesh__32.Parent = l__Head__6;
	end;
	local l__face__33 = v2:FindFirstChild("face");
	if l__face__33 then
		l__Head__6.face:Destroy();
		l__face__33.Parent = l__Head__6;
	end;
	v4.Name = p1;
	v4.Parent = p2;
	v2:Destroy();
	return v4;
end;
