Hard water often contains salts of calcium and magnesium. Soap molecules react with the salts of calcium and magnesium and forms a precipitate. This precipitate begins to float as an off-white layer over water. This layer is called scum. Soaps lose their cleansing property in hard water because of formation of scum.