Sword Animation

I’ve been trying to make my sword animation activate on mouse trigger but ive been haveing trouble. Im new at this and havent been scripting long so can someone help me.

something like (c#)

if (Input.GetMouseButtonDown(0))
	YourSword.animation.Play("NameOfAnimation");

should do that.