Soap's cleaning action is reduced when used in hard water. Hardness in water is caused by the presence of mineral salts of calcium (Ca) and magnesium (Mg),. These react with soap to form an insoluble precipitate, a soap film or scum. This reduces the amount of soap available for cleaning.
Reaction:
sodium stearate (aq) + calcium ions (aq) → calcium stearate (s) + sodium ions (aq)
Scum is the calcium stearate which is insoluble.