Pressing a button to make chat appear and disappear

public bool useChat = true;

if(useChat){
    				if(Input.GetKeyDown(KeyCode.Return)){
    					if(viewChat) {
    						viewChat=true;
    						print("true");
    					} else {
    						viewChat=false;
    						print("false");
    					}				
    				}

Im trying to make it so when I press enter it shows the chat and if I press enter again the chat disappears.
Right now when I press enter. Nothing shows up but in the console it says both true and false

You are only setting viewChat to true if viewChat is true… Is there some other code that also affects the viewChat variable?

I think what you want is

if(Input.GetKeyDown(KeyCode.Return)) //If you hit enter
{
   if(viewChat) //And if viewChat is true, meaning chat is open
   {
        viewChat = false; //Then close the chat
   }
   else
   {
       viewChat = true; //Otherwise turn chat on if the opposite is true
   }
   print(viewChat); //Show me what viewChat is every time I press enter
}

Snippet will toggle viewChat when Return is pressed, print true or false.

if( Input.GetKeyDown(KeyCode.Return) )
{
    viewChat = !viewChat;
	if ( viewChat ) Debug.Log ("true");
	else Debug.Log ("false");
}