Ca2+ and Mg2+ ions form insoluble calcium and magnesium soaps respectively when sodium or potassium soaps are dissolved in hard water. Soap2C17H35COOHNa+CaCl2→2NaCl+Insoluble calcium stearate (soap) (C17H35COO)2Ca
These insoluble soaps separate as scum in water and are useless as cleansing agent.