Hi, I have been working on a countdown script and I was able to get it like this:

var Text : GUIText;
private var starttime = false;

function start()
{
	starttime = true;
}

if (starttime == true)
{
StartCoroutine("CountDown");
  }


function CountDown(){
yield WaitForSeconds(1);
	Text.text = "3";
yield WaitForSeconds(1);
	Text.text = "2";
yield WaitForSeconds(1);
	Text.text = "1";
yield WaitForSeconds(1);
	Text.text = "GO!";
}

But when I start it doesn’t works, the GUIText isn’t updating, could someone explain me why is this doesn’t working?

There are two things wrong here.

  1. The Start function is not capitalized, so it won’t run.
  2. Your if (starttime == true) statement is outside of the Start function (or any other function), so it won’t run either.

So change your code to this:

var Text : GUIText;
private var starttime = false;

function Start()
{
    starttime = true;
    
    if (starttime == true)
	{
		StartCoroutine("CountDown");
	}
}

function CountDown()
{
	yield WaitForSeconds(1);
    Text.text = "3";
	yield WaitForSeconds(1);
    Text.text = "2";
	yield WaitForSeconds(1);
    Text.text = "1";
	yield WaitForSeconds(1);
    Text.text = "GO!";
}

and it will work as expected.

Thanks, now I feel like a noob :stuck_out_tongue: