When you heat an atom, some of its electrons are "excited* to higher energy levels. When an electron drops from one level to a lower energy level, it emits a quantum of energy. ... The different mix of energy differences for each atom produces different colours. Each metal gives a characteristic flame emission spectrum.
What are you trying to work out???