Delete Label from the script

Here’s my code:-

if(currentWaypoint==0)

	{
         if(move==0)

        	{

			   GUI.Label(Rect(0.8*Screen.width,0.12*Screen.height,0.1*Screen.width,0.5*Screen.height),"string1");

	        }

		    once = 0;
            if(once==0)
            {

               		if(move==0)

			        {

			          GUI.Label(Rect(0.8*Screen.width,0.12*Screen.height,0.1*Screen.width,0.5*Screen.height),"string2");

	                }

		   }
             
	}

But, the thing is: Both the strings are getting printed at the same time. I have to delete the string from either of the conditions. How to do that? Thanks in advance.

As long as your “move” variable is 0 it will always display both labels… I’m not sure what’s the desired behaviour, but i guess something like that. If move is 0 the first label is displayed for one frame (that’s really very short). From the next frame on the second label is displayed because the once variable is set to false.

var once : boolean = true;

// Somewhere in your code
if(currentWaypoint==0)
{
    if(move==0)
    {
        if(once)
        {
            GUI.Label(Rect(0.8*Screen.width, 0.12*Screen.height, 0.1*Screen.width, 0.5*Screen.height), "string1");
            once = false;
        }
        else
        {
            GUI.Label(Rect(0.8*Screen.width, 0.12*Screen.height, 0.1*Screen.width, 0.5*Screen.height), "string2");
        }
    }
}

Labels or other GUI elements can’t be removed or deleted. They have to be drawn each frame to be visible. At the moment you don’t call the Label function anymore it will disappear.