# Update cannot be coroutine?

**URL:** https://discussions.unity.com/t/update-cannot-be-coroutine/118780
**Category:** Questions & Answers
**Created:** [October 7, 2014, 3:51pm UTC](https://discussions.unity.com/t/update-cannot-be-coroutine/118780 "2014-10-07T15:51:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kainalex](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@Kainalex](https://discussions.unity.com/u/Kainalex)
#### Post date: [October 7, 2014, 3:51pm UTC](https://discussions.unity.com/t/update-cannot-be-coroutine/118780/1 "2014-10-07T15:51:04Z")

</div>

It says my Update() can not be a coroutine what should I Do to fix it

#pragma strict

var moveUp : KeyCode;  
var moveDown : KeyCode;

var speed : float = 15;  
function ResetPlayers ()  
{  
transform.position.y = 0;

```
 }

```

function Update ()  
{  
if (“ResetPlayers”) yield WaitForSeconds (4);  
}  
if (Input.GetKey(moveUp))

```
{
	rigidbody2D.velocity.y = speed;
}

if (Input.GetKey(moveDown))
{
	rigidbody2D.velocity.y = speed *-1;
}
else
{
	rigidbody2D.velocity.y = 0;
}

```

---

<div class="post-metadata">

### Author: ![Tourist](https://avatars.discourse-cdn.com/v4/letter/t/f4b2a3/32.png) [@Tourist](https://discussions.unity.com/u/Tourist)
#### Post date: [October 7, 2014, 3:58pm UTC](https://discussions.unity.com/t/update-cannot-be-coroutine/118780/2 "2014-10-07T15:58:09Z")

</div>

In the function OnEnable, start your update coroutine and stop it in OnDisable.

Your update coroutine should never end and be like :

```
IEnumerator MyUpdate()
{
  while(true)
  {
    // your code
    yield return null;
  }
}

```

This code sample is C#. Use the javascript equivalent if you need it.

But most important, what is the point of having a coroutine to manage an update?

---

<div class="post-metadata">

### Author: ![Anxo](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/anxo/32/256100_2.png) [@Anxo](https://discussions.unity.com/u/Anxo)
#### Post date: [October 7, 2014, 4:21pm UTC](https://discussions.unity.com/t/update-cannot-be-coroutine/118780/3 "2014-10-07T16:21:01Z")

</div>

Tourist was showing you in C# that you could just create a function that does your yielding for you. So you could have a external function that would reset the players

```
playersAreReady : bool = true;

function Update(){
   if(playersAreReady){
     //your code here. 
   }
}

function ResetPlayers(){
   playersAreReady = false;
   yield WaitForSeconds(4);
   playersAreReady = true; 
}

```

Then from somwhere else you can just reset players like this

```
ResetPlayers();

```

UC (Warning: Uncompiled code. Check for Errors. )
