yield WaitForSeconds problem?

Hello everyone.

I’ve create a ‘yield WaitForSeconds()’ and I want a message to change after specific seconds. My problem is that in the first ‘yield WaitForSeconds()’ I set the seconds to 2 for example, and on the second ‘yield WaitForSeconds()’ I set the seconds to 1. The problem is that it only reads the first ‘yield WaitForSeconds()’ and then it skips it all. Here is my code, please help me :slight_smile:

function second_textGUI(){
	first_text_message = "(Sshhh!!)";
	yield WaitForSeconds(3);
	first_text_message = "(Hmm.. who is he?)";
	yield WaitForSeconds(2);
	first_text_message = "(He might be the murderer!!!)";
	yield WaitForSeconds(3);
	first_text_message = "";
	second_en = false;
}

Any help is appriciated :slight_smile:

Edit: Is there any other way similar to yield WaitForSeconds() ?

Hey man I remember having the same issue a while back. In the end I just made a work around that ended up looking like this

    var firstWait  : boolean = true;
    var secondWait : boolean = false;
    function second_textGUI()
    {
         if(firstWait == true)
         {
              first_text_message = "(Sshhh!!)";
              yield WaitForSeconds(3);
              first_text_message = "(Hmm.. who is he?)";
              firstWait = false;
         }
         if(firstWait == false && secondWait == true)
         {
              yield WaitForSeconds(2);
              first_text_message = "(He might be the murderer!!!)";
              secondWait = false;
         }
         if(secondWait == false)
         {
              yield WaitForSeconds(3);
              first_text_message = "";
              second_en = false;
              //firstWait = true;     undo these comments if you want it to loop
              //secondWait = true;
         }
    }

I think the problem here is the fact that it doesn’t seem that you are updating the GUIText’s text. =0

I would go about that like this:

var GUITextMessages = GUIText;

function second_textGUI()
 {
 GUITextMessages.text = "(Sshhh!!)".ToString();
 yield WaitForSeconds(3);
 GUITextMessages.text = "(Hmm.. who is he?)".ToString();
 yield WaitForSeconds(2);
 GUITextMessages.text = "(He might be the murderer!!!)".ToString();
 yield WaitForSeconds(3);
 GUITextMessages.text = "".ToString();
 second_en = false;
 }

It may not work because I don’t usually work with GUI stuffs, so be prepared for errors! XD