IEnumerator corutine problem with playing animation trigger enter c#

hi, i want to make the object attack then stop and go back with the walk animation but the problem is that it plays the walk animation fine before the object trigger collides and starts the corutine. Now the attack animation and idle works but i can’t get the walk animation play again. So when i click to go it does walk animation but when the attack animation plays it goes back without hte walk animation playing again.

	// what you want to move......
	public Transform target;
	// object to go back.......
	public Transform back;
	// to choose the speed.........
	public float speed;
	// so that when you click the button it becoms true so that it can move to enemy......
	private bool Attack1 = false;
	// so thst when it becomes true the player goes back.....
	private bool arrive = false;
	// implement it in the movment.....
	private float step;



	void Update() {



		// to make step mean speed......
		step = speed * Time.deltaTime;
		// if attack1 is true then move and.......
				  if (Attack1 == true)
				{
						transform.LookAt (target);
			            goattack();
						animation.Play ("walk");
				}
		// if arrive is true then go back to start and idle......
		if (arrive == true) 
			{

			StartCoroutine("StopAnimation");

			}
		// if the model that has the script is in the same position as the starting place then.....
		if (transform.position == back.transform.position) 
		{
			arrive = false;
			animation.Play ("idle");
			transform.LookAt (target);
			
		}

		}

	// here are the instructions of what to do to attack the enemy........
	void goattack()
	
	{
		animation.Play ("walk");
		transform.position = Vector3.MoveTowards (transform.position, target.position, step);
	}

	// here are the instructions of what to do to go back to starting location..........
	void goback ()
	{
		 
		animation.Play ("walk");
		transform.position = Vector3.MoveTowards (transform.position, back.position, step);


	}

	// when the model enters a trigger box. what to do........
	void OnTriggerEnter(Collider name)
	{

		if (Attack1 == true) 
		{
			//animation.Stop ("walk");
			//animation.Play ("attack");

			Attack1 = false;
			arrive = true;


		}


	}
	// the gui items here buttons etc..........
	void OnGUI()
	{

		if (GUI.Button (new Rect (Screen.width / 2, Screen.height / 2, 200, 300), "Attack")) 
		
		{
			Attack1 = true;	

		}
	
	}

Did you setup walk animation as loop?

is there a need to make it loop ? because normally the idle attack and walk loops