The password box does not work in my game

i cant get my password box in my game to work… the username works properly
here is the code:
var mySkin : GUISkin;
var level : GameObject;

var GeneralWidth = 73; 

var LoaderHeight = 10;
var LoaderWidth = 10;

var LogHeight = 101;
var LogWidth = 163;

var PlayerUsername = "";
var PlayerPassword = "";

var UserHeight = 35;
var UserWidth = 1;

var PassHeight = 65;
var PassWidth = 1;

var GameOwner = "micky2171";
var GameOwnerPassword = "password";

var UsernameCORRECT = false;
var PasswordCORRECT = false;

function Start(){
	level.gameObject.active = false;
}

function Update (){
	
	if (PlayerUsername == GameOwner){
			UsernameCORRECT = true;
	}
		
	else {
			UsernameCORRECT = false;
	}
		
	
	if (PlayerPassword == GameOwnerPassword){
			PasswordCORRECT = true;
	}
	
	else {
			PasswordCORRECT = false;
	}
}

function OnGUI () {

	GUI.skin = mySkin;
	

	GUI.Box (Rect (LoaderHeight,LoaderWidth,220,120), "Log-in");
	

	PlayerUsername = GUI.TextArea (Rect(GeneralWidth,UserHeight,100,20),PlayerUsername);

		

	PlayerPassword = GUI.TextArea (Rect(GeneralWidth,PassHeight,100,20),PlayerPassword);
	
	if (GUI.Button (Rect (LogWidth,LogHeight,60,25), "Log-In")) {
		
		if(UsernameCORRECT == true){
		
			if(PasswordCORRECT == true){
			
		level.gameObject.active = true;
		
			}
			
		}
	}
	else
		{
				
		}
}

Hi, it is because the both GUI.TextAreas are on the same position (x=GeneralWidth (73)], y = 1, width = 100, height = 20). You should rename all variables too :slight_smile:

Example with hardcoded positions:

//                                 x   y    w   h  
PlayerUsername = GUI.TextArea(Rect(0,  0, 100, 20), PlayerUsername);
PlayerPassword = GUI.TextArea(Rect(0, 25, 100, 20), PlayerPassword);

Your code worked for me. One thing to note is that GameOwner and GameOwnerPassword are public variables. So your game is using the values in the Inspector, not the values in this script. The script values are only used at the time the script is attached. So if you made any changes in these values, it would account for your code not working.

Note you seems to be going the long way around to implement this functionality. Here is a bit of simplification. I’ve commented out the GUISkin and I use SetActive() to activate the game object:

#pragma strict
//var mySkin : GUISkin;
var level : GameObject;

var GeneralWidth = 73; 
 
var LoaderHeight = 10;
var LoaderWidth = 10;
 
var LogHeight = 101;
var LogWidth = 163;
 
var PlayerUsername = "";
var PlayerPassword = "";
 
var UserHeight = 35;
var UserWidth = 1;
 
var PassHeight = 65;
var PassWidth = 1;
 
var GameOwner = "Rob";
var GameOwnerPassword = "Password";

private var loggedIn = false;
 
function Start(){
    level.gameObject.SetActive(false);
}
 
function OnGUI () {
	if (!loggedIn) {
	    //GUI.skin = mySkin;
	    GUI.Box (Rect (LoaderHeight,LoaderWidth,220,120), "Log-in");
	    PlayerUsername = GUI.TextArea (Rect(GeneralWidth,UserHeight,100,20),PlayerUsername);
	    PlayerPassword = GUI.TextArea (Rect(GeneralWidth,PassHeight,100,20),PlayerPassword);
	 
	    if (GUI.Button (Rect (LogWidth,LogHeight,60,25), "Log-In")) {
	       if(PlayerUsername == GameOwner && PlayerPassword == GameOwnerPassword) {
	         	Debug.Log("Both Match");
	         	loggedIn = true;
	          level.gameObject.SetActive(true);
	 		}
	 		else {
	       }
		}
	}
}