Adding animation and play it on button pressed

I made an animation like this:

i selected my gun, then i go on window->animation and animation window popup, then i click “create new clip” and call it walk then i recorded animation moved may gun and other stuffs but i didn’t click add new cureve, but ther was 1 component added automaticly when i moved my gun its caled as gun. When i finished animating i press x and close animation window. Now when i click play button to test my game animation is playing whole time. then i made script to play it only when i press W button:

function Update () {
	if (Input.GetKeyDown("w")) {
		animation.Play("walk", PlayMode.StopAll);
	}
}

But when i press play button to test my game animation is still playing automaticly when i enter the game.

When i click on the my gun in Hierarchy window animation is show in Animator tab and my script there also.
Why this don’t work?

Learn about Animation Controllers. Much better and easier.

Animation controller