Very simple script need help thou

Hi im very bad at scripting and this is what i got so far:

var GunAnimation;
Input.GetButton (“fire1”);
animation.Play (“GunAnimation”);
function Update () {
}

im trying to get an animation played while pressing the fire button but it doesnt seem to work… can anyone tell me whats wrong?

look at my gun script in the showcase forums for a reference: http://forum.unity3d.com/threads/73294-Automatic-gun-script

I suggest you look at some of the beginning Javascript tutorials. There’s some on the wiki and can be found on the web also.

This is untested code, but your script should look something like this:

var gunAnimation : Animation;

function Update () {
  if (Input.GetButton ("fire1")) {
    gunAnimation.Play();
  }
}

Thanks for the fast response guys! i think i have what i need for now THANKS!!!

@Jibb3N
I would strongly suggest looking up some of the tutorials and read the documentation on using scripts for a basic understanding. Breaking the barrier of total obliviousness to scripting to basic understanding of structure (I feel) is very important to anyone who is going to even look at (much less work with) code. Also, since this script has to do with animation and input, I suggest going to the scripting reference section and look up part of the command you’re having problems with. Reverse engineer the scripts generously supplied by the developers and find out where pieces of the code is located.
-S