Why can't I run this wait function in my update?

It is supposed to happen but it doesn’t. Says I can’t do this in an update. What is wrong?

var LimbBroke : boolean = false;
var Bleeding : boolean = false;
var BloodLoss : float = 60;
var BodyArmature : GameObject;
var BodyMesh : GameObject;
var Blood : GameObject;
var SystemHealth : GameObject;
var Health : float = 300;

function Start ()
{

}

function Update ()
{
if(BodyArmature.GetComponent(LimbHealth).Health <= 0 && LimbBroke == false)
{
LimbBroke = true;
BodyMesh.renderer.enabled = false;
Blood.GetComponent(ParticleSystem).Play();
SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= Health;
Bleeding = true;
Bleed();
}

if(BodyArmature.GetComponent(LimbHealth).Health >= 100 && LimbBroke == true)
{
    LimbBroke = false;
    BodyMesh.renderer.enabled = true; 
    SystemHealth.GetComponent(MainPlayerHealth).MaxHealth += Health;
    Bleeding = false;
}

if(Bleeding == true) {
SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= BloodLoss;
yield WaitForSeconds(5);
}

}

function Bleed() {

if(Bleeding == true) {
SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= BloodLoss;
yield WaitForSeconds(5);
}
}

Update can’t be a coroutine. but you can start another coroutine from update.

can’t be a coroutine == you can’t use yield at all

Here, this should work.

var LimbBroke : boolean = false; 
var Bleeding : boolean = false; 
var BloodLoss : float = 60; 
var BodyArmature : GameObject; 
var BodyMesh : GameObject; 
var Blood : GameObject; 
var SystemHealth : GameObject; 
var Health : float = 300;

function Start () {

}

function Update () { 
 if(BodyArmature.GetComponent(LimbHealth).Health <= 0 && LimbBroke == false) { 
 LimbBroke = true; 
 BodyMesh.renderer.enabled = false; 
 Blood.GetComponent(ParticleSystem).Play(); 
 SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= Health; 
 Bleeding = true; 
 fixedUpdate(); 
 }

 if(BodyArmature.GetComponent(LimbHealth).Health >= 100 && LimbBroke == true)
 {
 LimbBroke = false;
 BodyMesh.renderer.enabled = true; 
 SystemHealth.GetComponent(MainPlayerHealth).MaxHealth += Health;
 Bleeding = false;
 }

function fixedUpdate() {
 if(Bleeding == true) {
 SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= BloodLoss;
 yield WaitForSeconds(5);
 }
 if(Bleeding == true) { 
 SystemHealth.GetComponent(MainPlayerHealth).MaxHealth -= BloodLoss; 
 yield WaitForSeconds(5); 
 } 
}

You can’t yield in Update and friends. You need a separate function.

function Start() {
  StartCoroutine(MyOwnUpdate());
}

function MyOwnUpdate() {
  while ( true ) {
    // this stuff happens every frame
    if ( startBleeding ) { Bleed(5); startBleeding = false; }
    yield;
  }
}

function Bleed( time : float ) {
  StartBleeding();
  yield WaitForSeconds(time);
  StopBleeding();
}