-- Head v1.1.1

assetUrl, fileExtension, x, y, baseUrl, mannequinId = ...

pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl) end)

game:GetService("ScriptContext").ScriptsDisabled = true

local mannequin = game:GetObjects(baseUrl.. "asset/?id=" .. tostring(mannequinId))[1]
mannequin.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
mannequin.Parent = workspace

local objects = game:GetObjects(assetUrl)
local mesh = objects[1]
if objects[1]:IsA("Folder") then
	for i, obj in pairs(objects) do
		if obj:IsA("Folder") and obj.Name == "R15ArtistIntent" then
			local head = obj.Head
			mannequin.Head:Destroy()
			head.Parent = mannequin
			if head:FindFirstChild("face") == nil then
				local face = Instance.new("Decal")
				face.Name = "face"
				face.Texture = "rbxasset://textures/face.png"
				face.Parent = head
			end
		end
	end	
else
	mannequin.Head.BrickColor = BrickColor.Gray()
	if mannequin.Head:FindFirstChild("Mesh") then
		mannequin.Head.Mesh:Destroy()
	end
	mesh.Parent = mannequin.Head
end

for _, child in pairs(mannequin:GetChildren()) do
	if child:IsA("BasePart") and child.Name ~= "Head" then
		child:Destroy()
	end
end


return game:GetService("ThumbnailGenerator"):Click(fileExtension, x, y, --[[hideSky = ]] true)