GUI question

Hi all. Need some help. Im working on a game, and I have encountered this problem…
To be more specific, I’m really new to scripting… aand…

I want to have a GUI label text fade in and fade out when the player enters or leaves the trigger area, accordingly . Lets say, when the player approaches a flashlight with a sphere collider in a specific distance to pick it up, I want the GUI to slowly fade in with “Press key E to pick up the flashlight”, and continue to display this text while the player is still in the triggered area and when he finally picks the flashlight, then I want the GUI to fade in with “Press key F to toggle the flashlight”, wait for the player to press the button, and then fade out once the key is pressed, never to appear again…

The code for picking up the flashlight so far:

var SpawnTo : Transform;

var Flashlight : Transform;

var dist = 3;

private var isHolding = false;

function Update () {
 
    if(Input.GetKeyDown ("e")){ 
 
        if(Vector3.Distance(transform.position, Flashlight.position) < dist) 
 
        {
 
            isHolding = !isHolding; 
 
            }
 
            }
 
 
 
    if(isHolding == true){
 
        Flashlight.rigidbody.useGravity = false; 
 
 
        Flashlight.parent = SpawnTo; 
 
 
        Flashlight.transform.position = SpawnTo.transform.position; //sets position
 
 
        Flashlight.transform.rotation = SpawnTo.transform.rotation; //sets rotation
 
        }
 
        else{ 
 
          
        }
    }

Any help appreciated :slight_smile:

Follow this answer Fade in Gui Label - Questions & Answers - Unity Discussions