Why does my text doesn't stay on screen?

Hi! As you might imagine, I’m kinda new to this scripting, programming thing. I’m trying to create a text game ( You know, those old school games with only text on the screen?). I’m trying to make an if statement about a key or something. I want my text to change if the bool ‘‘haskey’’ is false.

I can see the text wants to change but it changes back to the original text. My script looks like that.

void State_OutsideCell1 () {
hasKey1 = false;
text.text = “you see a door and a key, press T to take the key or press D to open the door.”;

	// You have the key and you open the door
	if (hasKey1 =	= true && Input.GetKeyDown (KeyCode.D)) {
		text.text = "You enter the door blablabla";
		myStates = States.whatever;
	}

	// You don't have the key
	if (Input.GetKeyDown (KeyCode.D) && hasKey1 == false) 
		text.text = "You don't have a key press blabla to blabla.";

}

I’m pretty sure it has something to do with the first line but I don’t know how to change it so it’s not THE line of the method.

Thanks for your help!

void State_OutsideCell1 () {

			if (hasKey1 == false)
			text.text = "You are in front of a door and there is a key to your left. 

Press o to open the door
Press T to take the key.";
{
if (hasKey1 == true)
text.text = “You have a key in hand. press o to open the door”;

			else if (hasKey1 == true & Input.GetKeyDown (KeyCode.O)) 
			myStates = States.door1;

			else if(hasKey1 == false & Input.GetKeyDown(KeyCode.T))
				text.text = "You don't have a key! Press T to take the key.";
			hasKey1 = true;
			
		}
	}

I’m trying something like that. It just wont work. when I enter this ‘‘Room’’, it makes haskey1 true and the text is ''You are in front of a door and there is a key to your left (…) ‘’.

I’m pretty sure it has everything to do with the way I typed my if statements and the curly bracers.

Note: I made a way over complicated system to make this work but I don’t want to use that. See for yourself.

	/* void State_OutsideCell1 () {
		text.text = "As you get closer to the door, it gets bigger. You think it is a bit intimidating. Your head starts to hurt like crazy. " +
			"What is behind that door? To your left, there is a key on the wall.

press T to take the key.

press D to open the door. ";
if (hasKey1 == true && Input.GetKeyDown (KeyCode.D)) //
myStates = States.door1;
else if (Input.GetKeyDown (KeyCode.D) && hasKey1 == false) //
myStates = States.HasNoKey1;
else if (Input.GetKeyDown (KeyCode.T) && hasKey1 == false) //
myStates = States.Key1;
else if (Input.GetKeyDown (KeyCode.T) && hasKey1 == true) //
myStates = States.HasKey1;
}
void State_HasKey1 () {
text.text = “you already took the key and There is nothing left on the wall. Press B to go back”;
if (Input.GetKeyDown (KeyCode.B))
myStates = States.OutsideCell1;
}

	void State_HasNoKey1 () {
		text.text = "You feel nauseous as you reach for the door knob. Why is that? The door is locked and you can't open it without a key." +
			"Press B to go back";
			if(Input.GetKeyDown(KeyCode.B))
				myStates = States.OutsideCell1;
	}
	void State_Key1 () {
		text.text = "Has you reach for the key, your head suddenly feels like it is going to explode. You take a deep breath and clear your mind." +
			"

press t to take the key";
hasKey1 = true;
if (Input.GetKeyDown (KeyCode.T))
myStates = States.OutsideCell1;

	}

	void State_Door1 () {
		text.text = "You use the key on the lock and open the door. you shit on your chest. press anykey to masturbate.";
	} */

it’s just too long and stupid… But it works… ^,^