As always with supplements, a deficiency might cause the issue (cramps in this case) and the supplement gets you back to normal levels, preventing cramps. If you’re experiencing cramps but don’t have a magnesium deficiency, taking magnesium supplements won’t make the cramps go away.