Each metal ion gives a flame colour that can be used to name it. Lithium ions give a crimson flame. Sodium ions give a yellow flame. Potassium ions give a lilac flame. Calcium ions give an orange-red flame. Copper ions give a green flame.
The colour comes from the metal ion, not from the other ion in the compound. Copper chloride and copper sulfate both give a green flame, because both contain copper ions. A flame test therefore identifies the metal and says nothing about the non-metal ion.
Flame tests have limits. Sodium compounds are present as impurities in many samples, and even a small amount gives a strong yellow flame that can hide the colour of another metal ion. A mixture of metal ions can also be hard to read.