Programming a Sword Swing Animation and Swapping weapons

I have a sword swinging animation, but I need help playing it when my character attacks.

Also, what is the best way to get my character to alternate from a sword to a gun?

Linking your duplicate question’s best answer here: http://answers.unity3d.com/questions/63832/can-you-write-me-a-script-for-my-sword-attacking-a.html