just found my old module from my avatar editor game
i didnt consider converting emotes in this module cuz i have a custom made emote system in my game before but if you really wish to also convert the emotes you can get the emotes from using :GetEmotes() on humanoiddesc i believe
local Module = {}
Module.HumanoidDescriptionProperties = {
"BackAccessory", "FaceAccessory", "FrontAccessory", "HairAccessory", "HatAccessory", "NeckAccessory", "ShouldersAccessory", "WaistAccessory",
"ClimbAnimation", "FallAnimation", "IdleAnimation", "JumpAnimation", "MoodAnimation", "RunAnimation", "SwimAnimation", "WalkAnimation",
"HeadColor", "LeftArmColor", "LeftLegColor", "RightArmColor", "RightLegColor", "TorsoColor",
"BodyTypeScale", "DepthScale", "HeadScale", "HeightScale", "ProportionScale", "WidthScale",
"Face", "Head", "LeftArm", "LeftLeg", "RightArm", "RightLeg", "Torso",
"GraphicTShirt", "Pants", "Shirt",
}
function Module:HumanoidDescriptionToTable(HumanoidDescription:HumanoidDescription):{string}
local HumanoidDescriptionData = {}
HumanoidDescriptionData.LayeredClothing = {}
for Index, Value in ipairs(Module.HumanoidDescriptionProperties) do
if HumanoidDescription[Value] then
if table.find({"HeadColor", "LeftArmColor", "LeftLegColor", "RightArmColor", "RightLegColor", "TorsoColor"}, Value) then
HumanoidDescriptionData[Value] = {R = HumanoidDescription[Value].R * 255, G = HumanoidDescription[Value].G * 255, B = HumanoidDescription[Value].B * 255}
else
HumanoidDescriptionData[Value] = HumanoidDescription[Value]
end
end
end
for Index, Value in ipairs(HumanoidDescription:GetAccessories(false)) do
table.insert(HumanoidDescriptionData.LayeredClothing, {
AccessoryType = Value.AccessoryType.Name,
AssetId = Value.AssetId,
Order = Value.Order,
})
end
return HumanoidDescriptionData
end
function Module:TableToHumanoidDescription(HumanoidDescriptionData:{string}):HumanoidDescription
local HumanoidDescription = Instance.new("HumanoidDescription")
for Index, Value in ipairs(Module.HumanoidDescriptionProperties) do
if HumanoidDescriptionData[Value] then
if table.find({"HeadColor", "LeftArmColor", "LeftLegColor", "RightArmColor", "RightLegColor", "TorsoColor"}, Value) then
HumanoidDescription[Value] = Color3.fromRGB(HumanoidDescriptionData[Value].R, HumanoidDescriptionData[Value].G, HumanoidDescriptionData[Value].B)
else
HumanoidDescription[Value] = HumanoidDescriptionData[Value]
end
end
end
local LayeredClothingData = {}
for Index, Value in ipairs(HumanoidDescriptionData.LayeredClothing) do
table.insert(LayeredClothingData, {
AccessoryType = Enum.AccessoryType[Value.AccessoryType],
AssetId = Value.AssetId,
Order = Value.Order
})
end
HumanoidDescription:SetAccessories(LayeredClothingData, false)
return HumanoidDescription
end
function Module:CheckWearingClothes(Character:Model)
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
local ShirtNeeded = true
local PantsNeeded = true
local HumanoidDescription = Humanoid:GetAppliedDescription()
for Index, Value in ipairs(HumanoidDescription:GetAccessories(false)) do
if Value.AccessoryType == Enum.AccessoryType.DressSkirt then
ShirtNeeded = false
PantsNeeded = false
elseif Value.AccessoryType == Enum.AccessoryType.Pants then
PantsNeeded = false
ShirtNeeded = false
elseif Value.AccessoryType == Enum.AccessoryType.Shorts then
PantsNeeded = false
ShirtNeeded = false
elseif Value.AccessoryType == Enum.AccessoryType.Shirt then
ShirtNeeded = false
elseif Value.AccessoryType == Enum.AccessoryType.TShirt then
ShirtNeeded = false
elseif Value.AccessoryType == Enum.AccessoryType.Sweater then
ShirtNeeded = false
elseif Value.AccessoryType == Enum.AccessoryType.Jacket then
ShirtNeeded = false
end
end
if ShirtNeeded and HumanoidDescription.Shirt ~= 0 then
ShirtNeeded = false
end
if PantsNeeded and HumanoidDescription.Pants ~= 0 then
PantsNeeded = false
ShirtNeeded = false
end
if PantsNeeded then
local function ColorSimilarity(Color1, Color2)
local R1, G1, B1 = Color1.R, Color1.G, Color1.B
local R2, G2, B2 = Color2.R, Color2.G, Color2.B
return math.sqrt((R1 - R2)^2 + (G1 - G2)^2 + (B1 - B2)^2)
end
if ColorSimilarity(HumanoidDescription.TorsoColor, HumanoidDescription.LeftLegColor) >= 0.125 and ColorSimilarity(HumanoidDescription.TorsoColor, HumanoidDescription.RightLegColor) >= 0.125 then
PantsNeeded = false
ShirtNeeded = false
end
end
for Index, Value in ipairs(Character:GetChildren()) do
if Value:IsA("Shirt") then
if ShirtNeeded then
Value:Destroy()
elseif Value.Name == "DefaultShirt" then
Value:Destroy()
end
end
if Value:IsA("Pants") then
if PantsNeeded then
Value:Destroy()
elseif Value.Name == "DefaultPants" then
Value:Destroy()
end
end
end
if ShirtNeeded then
local DefaultShirt = Instance.new("Shirt")
DefaultShirt.Name = "DefaultShirt"
DefaultShirt.Parent = Character
DefaultShirt.ShirtTemplate = "http://www.roblox.com/asset/?id=855768337"
end
if PantsNeeded then
local DefaultPants = Instance.new("Pants")
DefaultPants.Name = "DefaultPants"
DefaultPants.Parent = Character
DefaultPants.PantsTemplate = "http://www.roblox.com/asset/?id=867830078"
end
end
end
return Module