How to hide a text and show another when Space bar is clicked?,How to hide text after pressing space?

void Update()
{
if (active==true)
{
Motion();
Rotate();
}
else
{

        }

        // Below is set of lines to be displayed once player face them
        var fwd = transform.TransformDirection(Vector3.forward);
        if (Physics.Raycast(transform.position, fwd, out hit, Reach) && hit.transform.tag == "Bed")
        {
            interaction.SetActive(true);
            if (Input.GetKey(KeyCode.Space))
            {
                bedLine.SetActive(true);
            }
        }
        else if (Physics.Raycast(transform.position, fwd, out hit, Reach) && hit.transform.tag == "Toilet")
        {
            interaction.SetActive(true);
            if (Input.GetKey(KeyCode.Space))
            {
                toiletLine.SetActive(true);
            }
        }
        else if (Physics.Raycast(transform.position, fwd, out hit, Reach) && hit.transform.tag == "Speaker")
        {
            interaction.SetActive(true);

            if (Input.GetKey(KeyCode.Space))
            {
                speakerLine.SetActive(true);
                interaction.SetActive(false);
            }

        }

So, in the second “else if”, I would like for the interaction line to hide and speaker line to show. I tried to include another if statement but it didn’t change anything. Thus, in my game, whenever I go near the object with speaker tag, interaction appears as it should but when i press space bar the interaction line hide and shows resulting in showing both lines.

by the way I’m 2 weeks old with Unity :slight_smile:

Move this line

Input.GetKey(KeyCode.Space)

To the top of your code and capture it in a boolean value that you can reference later. Or better yet, have a function called CollectInput that checks that stuff for you. See if it is correctly firing by printing its value.