Coroutine While loop help

I have a coroutine with a while loop that I’d like to keep repeating for a couple seconds until a condition is met but it isn’t looping through multiple times so I cant make a gun look at another object using slerp. What is causing the while loop to be run one time then shut off? What is the best way to make a while loop run until a condition is met? Would a bool be the best way or no? The code below is suppose to run for a couple seconds then by the time the waitforseconds is done the gun should be done moving. Is this the best way to do this? Thanks for the info

  public IEnumerator LookAt1()
    	{
    		
    		LookAt = true;
    
    		
    
    		while (LookAt == true) {
    
    			//Body
    			Quaternion Rot1 = Quaternion.LookRotation (RM.Priority1Plastic [0].transform.FindChild ("LookAt1").position - this.gameObject.transform.position);
    			this.gameObject.transform.rotation = Quaternion.Slerp (this.gameObject.transform.rotation, Rot1, Time.deltaTime * 3);
    
    			//Gun
    			Quaternion Rot = Quaternion.LookRotation (RM.Priority1Plastic [0].transform.FindChild ("LookAt1").position - Gun.transform.position);
    			Gun.transform.rotation = Quaternion.Slerp (Gun.transform.rotation, Rot, Time.deltaTime * 3);
    
    		}

yield return new WaitForSeconds (3);
    
    		LookAt = false;


    	}

If you want the code in your Coroutine to run for 3 seconds then this should do the trick:

public IEnumerator LookAt1()
{
    float duration = Time.time + 3.0f;
    while (Time.time<duration)
    {
        // Put  your code in here
        yield return null;
    }
}

Hope this helps out, be sure to let me know if you need any additional help, this is my first time answering here! (b")b

Adding a return of any kind will immediately terminate the rest of the code.