Residents were shocked to find a man exposing himself outside their homes as they were sleeping