Why soap form a scum in hard water?
Hard water contains dissolved calcium (Ca2+) and magnesium (Mg2+) ions dissolved in it. Soap consists of sodium or potassium salts derived from fatty acids. In hard water, calcium and magnesium ions react with soap molecules which results in the formation of insoluble precipitates called scum. The chemical reaction between soap and hard water -$$
2C_{17}H_{35}COO^-Na^+ + Ca^{2+} \rightarrow (C_{17}H_{35}COO)_2Ca \downarrow + 2Na^+
$$
here (C17H35COO)2Ca- Calcium stearate (insoluble precipitate -scum), Na+- Sodium ions remain dissolved in water.