Answer :
When you are doing a flame test you are using a solution of positive metal cations and negative metal anions. The reason a color is observed is that during the flame test the positive ion can reacquire an electron, becoming a neutral element again. The electron that is gained is in a higher energy level and when it drops to a lower energy level a photon of light is emittted. The wavelength of the light emitted determines the color.