The collective motion of Bacillus subtilis in the presence of a photosensitizer is disrupted by reactive oxygen species when exposed to light of sufficient dosages and is partially recovered when light irradiation is suspended. The transition from a highly collective to a more random motion is modeled using an improved self-propelled model with alignment rule. The increment in noise level describes the enhanced uncertainty in the motion of swarming bacteria under stress as observed experimentally.