WaitForSeconds not working at all C#

I have a class file that zooms the camera for aiming. I also have a zoom animation for my gun. What i want to do is wait for the gun to catch up some before i do the camera zoom. It zooms by the right mouse button down event

However, it just doesnt seem to do anything like the function is not being called. I have looked at numerous examples and i dont see what i am doing wrong?

UPDATE: I got it fixed. I will revise my code to reflect that incase anyone else has problems down the road.

void Update () {
		
		
	StartCoroutine("fieldOfView");
			
	}


	IEnumerator fieldOfView(){   // Not IEnumerable
		
		if(Input.GetMouseButtonDown(1)){
			
			aim = true;
			
			ready = false;
			
		}
		if(Input.GetMouseButtonUp(1)){
			aim = false;
		}
		
		if(aim){
			
			yield return new WaitForSeconds(2);
			 
			cam.camera.fieldOfView = Mathf.Lerp(cam.camera.fieldOfView, distance, speed * Time.deltaTime);
		}
		if(!aim){
	
			cam.camera.fieldOfView = Mathf.Lerp(cam.camera.fieldOfView, original_position, speed * Time.deltaTime);
		}
		
		
		
	}

Every example i have tried has not worked.

It seems to actually work perfectly in your code.

Starting a coroutine means “executing another piece of code at the same time that your current piece of code”. So you’re just “waiting” but this does only pause the coroutine code… not the main “thread”.

Even if it doesn’t seem to wait 5 seconds it actually does, but not in your main execution thread that’s why it seems buggy for you.

I would suggest something using a boolean to control your flow. Something like this:

void Update () 
{
  if ( ready == false ) // check if you're no in the 5s delay
  {
    return; 
  }

  if(Input.GetMouseButtonDown(1))
  {
    aim = true;
    ready_to_anim = false; // set the boolean to false == your not allowed to do something for 5s
    StartCoroutine("wait");
    return;
  }
  // rest of your code
}

IEnumerator wait() 
{
   yield return new WaitForSeconds(5);
   ready_to_anim = true; // delay is over now you can do something
}

I did not read the code carefully to trace it and see what in each state will happen but your coroutine is returning IEnumerable instead of IEnumerator and it should be the reason for it to not work.