Change character appearance based on stats (Attribute system)

  1. What do you want to achieve?

I want to make a system where Player instance (in ‘Players’ hierachy) have list of attributes such as EyeColor, HairColor, SkinTone, Race, etc and my goal is changing player’s apperance based on stats it had, Example: if there’s brown eye stat then, it should have brown eyes and there’s white hair, then character model should had white hair, ETC…

I already made working data-saving attributes on player instance, the only problem I am having is trying to change player’s appearance based on what stats they have.

The picture of attribute list I was talking about:
image

So, how would I make it possible for player’s appearance to change accordingly to the attributes?

You could try and make a script that gets the player’s humanoid description [:GetAppliedDescription()] and make variables to change the values of the humanoid description depending on the player character’s attributes (body colors, accessories, limb scaling, clothing, etc.). Then apply it to the player character [:ApplyDescription()].

Again I am only suggesting this from experience and you may have a different approach on this, like specific details such as eye color.

Sorry for late reply, but how would I compare player’s attribute and tell code to change character to look like that? I don’t really understand how GetAppliedDescription works.

You can try making tables/dictionaries to store certain values for certain attributes.

For instance I made made a script that sets the character’s skin color based on an attribute (which I made in the rig’s Humanoid instance):

local humanoid = script.Parent.Humanoid
local toneAttribute = humanoid:GetAttribute("SkinTone")

local skinTones = {
	["PastelBrown"] = Color3.fromRGB(255, 204, 153),
	["Nougat"] = Color3.fromRGB(204, 142, 105),
	["DarkOrange"] = Color3.fromRGB(160, 95, 53)
}

local thisDescription = humanoid:GetAppliedDescription()

local function set()
	for i, v in pairs(skinTones) do
		if i == toneAttribute then
			thisDescription.HeadColor =  v
			thisDescription.LeftArmColor =  v
			thisDescription.RightArmColor =  v
			thisDescription.LeftLegColor =  v
			thisDescription.RightLegColor =  v
			thisDescription.TorsoColor = v
			break;
		end
	end
	
	humanoid:ApplyDescription(thisDescription)
end

set()

Basically what GetAppliedDescription does is return the entire Description of the character’s humanoid, which stores values about its looks like its body colors, clothing and accessory ids.

With the returned description from the variable thisDescription I edited its body color values, which you can find in the Humanoid hierarchy here:
Screenshot 2024-01-04 154549

Screenshot 2024-01-04 154602

And ApplyDescription is basically what it is, applies the modified description returned earlier.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.