Every substance produces light of different colors on the basis of level of energy that is possessed by the electrons of a substance.
Explanation:
Every substance has its level of energy. Depending upon that energy level the light of different colors id produced. There are electrons present in every substance that is made up of atoms and those atoms consist of electrons.
Whenever an atom is heated, the electrons present get excited and their energy level also increases but when their energy level comes down they emit energy in the form of light. The color of that light depends upon the level of energy of an electron. Each substance emits its color.