how do I make it where the hair color of an icon can change, but not the entire icon? in other words if I have an icon with black clothing and black hair, how do I make the hair color customizable while everything else is unchanged?

You'll have to make a new icon that contains just the hair. You can color it at runtime with rgb() or simply have preset colors that are each seperate icons. Then you attach the customized hair icon to the mob as an overlay.

how do I make it where the hair color of an icon can change, but not the entire icon? in other words if I have an icon with black clothing and black hair, how do I make the hair color customizable while everything else is unchanged?

First, you need to make an icon with two states: One is called "body" and has the body and head. Make another called "hair", that's mostly white or shades of gray (or slightly off-white colors); this is going to be tinted by a color. You can do the same thing with clothes that you do with hair here, or you can just make clothes part of the body.

For the sake of example, let's say these icon states are now in player.dmi.

However, the one drawback to this technique is that the final icon has no states except the default "". If you want to have icon states set up and everything, the process is more complicated.

First, you have to create multiple icon files. Make one for the body, one for the hair, and so on. Each file should have exactly the same icon states. If you use directional icons, they should have icons with the same directions. If you use animated icons, make the corresponding states in each icon file have the same number of frames. And so on.

Now, let's say these files are called player_body.dmi, player_hair.dmi, etc.