How to set text off or on?

I have two text that shows in the first level of my game. My code is running perfectly only for one thing. What I am trying to do where it shows (Hi, Press enter to begin!), and when you do(press w to go forward and space to jump). The Enter key is working fine, but when I start the level, it shows both texts at once; is there any way to fix this? Here is the code I used:

using UnityEngine;
using System.Collections.Generic;


public class textswitch001 : MonoBehaviour {
    public GameObject text001;
    public GameObject text002;

    void Update() {
        if (Input.GetKeyDown(KeyCode.Return)) {
            text001.SetActive(true);
            text002.SetActive(false);
        }
        if (Input.GetKeyUp (KeyCode.Return)) {
            text001.SetActive (false);
            text002.SetActive (true);
        }
    }
}

thanks,
steel

Well, you could add a Start() method that deactivates the text you don’t want to see.

Or, you could simply deactivate that text in the scene hierarchy using the Inspector.

In addition to disabling one in Start, I’d suggest that you disable this script after the KeyUp event, otherwise anytime a player hits the enter key, these same actions will be taken :slight_smile: