Certain nutrients play essential roles in the production of melanin, the pigment responsible for hair color. For instance, deficiencies in vitamins like B12, D and E, and minerals like copper and iron can impact melanin production and overall hair health. When the body lacks these vital nutrients, it might affect the health and function of the hair follicles, potentially leading to changes in hair color.