When it becomes an ion, it donates its valence electrons and becomes positively charged. The positively charged ion would be Mg²⁺ because it loses two electrons. It would have 12 protons and 10 electrons.
For solving this first of all you figure out the formula of iron(3)oxide so you look at the periodic table as you said valency of iron is 3 positive because metals are always positive and oxygen’s valency is 2 (negative because non-metal). You criss-cross both you take 2 from oxygen and put it under the iron and then 3 from iron under oxygen.
Valency is the number of electrons needed to be a noble gas.
Oxygen has 6 electrons in the outer shell and it needs 2 more to become noble gas.
The total number of electrons needed in every shell is 8 so to figure out valency you subtract the number of electrons in the outer shell from 8. Valency also shows how many electrons you need to share for bonding.