Elegant solution to play certain animations depending on what weapon a player is using?

Quite helpful.
I have been searching the forums and google, with very little results. Was going to post a question myself until I saw this answer!