Trouble accessing animations from other GameObject

So I'm trying to access my object tagged "Player" animations in the script that is on his gun, so I did this(I'm slimming it down just to ask about the important parts):

Code:

function Update(){
   var player = GameObject.FindWithTag("Player");
   player.animation.Play("Shoot");
}

This works fine, but I want to change the animation's WrapMode to once, so I need to find the animation in Start(), before Update().

But, if I create the "var player" in Start(), Update() can't use that variable. Should I create it twice?

Or can I create it outside of all the functions at the top as a private variable?

Yes, if you create your variable outside all the functions, and the variable will persist throughout all the functions:

var player : GameObject;

function Start() {
   player = GameObject.FindWithTag("Player");
}

function Update(){
   player.animation.Play("Shoot");
}

var player : GameObject;

function Start() {
// tag you object to player
player = GameObject.FindWithTag(“Player”);
}

player.animation.wrapMode = WrapMode.Loop;

player.animation[“jump”].wrapMode = WrapMode.Clamp;
player.animation[“shoot”].wrapMode = WrapMode.Clamp;

player.animation[“idle”].layer = -1;
player.animation[“run”].layer = -1;

player.animation.Stop();

function Update () {
if (Mathf.Abs(Input.GetAxis(“Vertical”)) > 0.1)
player.animation.CrossFade(“run”);
else
player.animation.CrossFade(“idle”);
if (Input.GetButtonDown (“Jump”))
player.animation.CrossFade(“jump”);

if (Input.GetButtonDown ("Fire1"))
	   player.animation.CrossFadeQueued("shoot", 0.3, QueueMode.PlayNow);

}