I saw this question many times in different variations.
It seems that before the light is turned on second time, people who has black hat should slap their face.
For example, assume there are two people wearing the black hat. After the light is turn on and off once, there is no sound. This means everybody knows there must be more than one black hat. Then the two people wearing black hat should slap their face because they only saw one hat. Could you modify the question so that it makes sense?