luaroblox

Can I avoid humanoid:ApplyDescription resetting previous changes made to humanoid?


In my roblox game I'm currently making a character creation system, and the only way I found to change the player's face is through humanoid:ApplyDescription. Here's how I'm currently using it:

elseif changeName == "Face" then
    local humanoid = character:FindFirstChild("Humanoid")
    local description = humanoid:GetAppliedDescription()
    description.Face = v2.Value -- Id of the face
    humanoid:ApplyDescription(description)

When changing the face in game using this system, the player's skin color gets reset. Here's how I'm changing the player's skin color:

elseif changeName == "Skin" then
    if character:FindFirstChild("BodyColors") then
        character.BodyColors:Destroy()
    end
    local bodyColors = v2:Clone()
    bodyColors.Name = "BodyColors"
    bodyColors.Parent = character

I'm pretty sure that this resets the skin color because I'm not using humanoid:ApplyDescription to change the player's skin color, but if I were to do that then things would get a lot more complex due to how I'm currently storing the color of each option (within a folder with the different body colors for each option).

I've tried using humanoid:ApplyDescriptionReset instead but this makes the problem worse by also resetting the player's clothing choices. If there's a different way to change the player's face, then I think that would fix the issue, but I couldn't find any other ways online or in the documentation.


Solution

  • Turns out it wasn't as complex as I thought it would be. All I had to do was add this to the part that updates the player's skin color:

    elseif changeName == "Skin" then
        if character:FindFirstChild("BodyColors") then
            character.BodyColors:Destroy()
        end
        local BodyColors = v2:Clone()
        BodyColors.Name = "BodyColors"
        BodyColors.Parent = character
        
        --What I added              
        local humanoid = character:FindFirstChild("Humanoid")
        local description = humanoid:GetAppliedDescription()
        description.HeadColor = BodyColors.HeadColor3
        description.LeftArmColor = BodyColors.LeftArmColor3
        description.LeftLegColor = BodyColors.LeftLegColor3
        description.RightArmColor = BodyColors.RightArmColor3
        description.RightLegColor = BodyColors.RightLegColor3
        description.TorsoColor = BodyColors.TorsoColor3
        humanoid:ApplyDescription(description)
    

    This uses humanoid:ApplyDescription to update the skin color after changing replacing the BodyColors instance within the character, so when updating the face via the same method the skin color no longer gets reset.