Answer
The photoelectric effect knocks electrons off the negatively-charged ball, discharging it.
Work Step by Step
If the metal ball of an electroscope is negatively charged, it has excess electrons that can be ejected from the ball by ultraviolet light.
On the other hand, if the ball is positively charged, it already has fewer electrons than protons. Shining ultraviolet light on it, and ejecting even more electrons, just increases the net positive charge.