Sounds like a dodgy earth.
9/10 of electrical probs on cars and particularly bikes are bad/corroded earths.
Double check behind the light where all the connections are and make sure the female parts of the connectors haven't become loose. If they have give them a little tweak with a pair of pliers being careful not to squash them.
Hope this helps
