Unity Javascript debug error stating BCE0044: expecting :, found ';'. Any help?

I’m sure, for what I want to accomplish, there are many problems with this script, but the one that’s stopping me in my tracks right now is Unity saying there should be a colon and I’ve absolutely no idea how that makes any sense, and I’ve looked up quite a bit on the topic online to no avail. Any help would be massively appreciated, and I’ll give any extra information if it’s necessary. Thank you very much in advance if you can suggest anything or help at all.
So, here’s my script (with // annotations describing things)-

#pragma strict
//Main character collides with village, and 'enters' it.

var visitedvillage = false;//variable stating that the character has (or has not, for false) visited the village recently. Here to make sure that after exiting the menu, the collision will not trigger again (since the character will still be colliding with the village object) until the variable is removed (by exiting contact with the object, or after a set time has passed, presumably). As of right now, you will only be able to visit the villageo once per game start, but that's not really a problem for the time being.

var mediumvillagescreentoggle = false;//variable simply stating that the village menu is not currently open (false).

function OnControllerColliderHit (hit : ControllerColliderHit) {

	if(hit.collider.gameObject.name == "Structure_Village_Medium.01") {
		if (visitedvillage == "false"){//when the main character collides, it checks if they have already visited the village recently, if they have (true) it will not fire and nothing happens, preventing an endless loop of opening the menu each time you close it once you collide with the village.
			mediumvillagescreentoggle = "true";//toggles the village menu
			if (mediumvillagescreentoggle == "true") {//not sure where else to put this besides here, though this basically jsut turns on the menus/buttons when true.
				OnGUI(); {
					GUI.Box(Rect(110,10,400,300),"Medium Village");//should open a box, right? but unity says BCE0044: expecting:, found ';'. I have no idea how this makes sense.. any help is greatly appreciated.
				}
				OnGUI(); {//added a second independent OnGUI in hopes it would help. It doesn't seem to have done anything, or hurt anything, so I haven't removed it.
					if (GUI.Button=(Rect(120,40,180,60), "Leave Village")) {//should simply open a button that, when clicked, turns off the village menu.
						mediumvillagescreentoggle = "false";
					}
				}
				visitedvillage = "true";
				}
			}
		}
	}
}

You can’t define OnGUI inside other functions. OnGUI is a callback function. It needs to be a member function of your script. What you’ve done here makes no sense at all :wink:

Next thing is you can’t assign a string “true” to a boolean. UnityScript is not (web)javascript, it’s way different.

function OnControllerColliderHit (hit : ControllerColliderHit) {
    if(hit.collider.gameObject.name == "Structure_Village_Medium.01") {
        if (visitedvillage == false){
            mediumvillagescreentoggle = true;
        }
    }
}

function OnGUI() {
    if (mediumvillagescreentoggle) {
        GUI.Box(Rect(110,10,400,300),"Medium Village");
        if (GUI.Button=(Rect(120,40,180,60), "Leave Village")) {
            mediumvillagescreentoggle = false;
        }
    }
}

On line 12/19/22 you are setting BOOLEAN variables to STRING, i think this is not possible. remove the “”.

Next is that you are calling OnGUI in there, i suggest you to do the following:

#pragma strict
//Main character collides with village, and 'enters' it.
 
var visitedvillage = false;//variable stating that the character has (or has not, for false) visited the village recently. Here to make sure that after exiting the menu, the collision will not trigger again (since the character will still be colliding with the village object) until the variable is removed (by exiting contact with the object, or after a set time has passed, presumably). As of right now, you will only be able to visit the villageo once per game start, but that's not really a problem for the time being.
 
var mediumvillagescreentoggle = false;//variable simply stating that the village menu is not currently open (false).
 
function OnControllerColliderHit (hit : ControllerColliderHit) {
 
    if(hit.collider.gameObject.name == "Structure_Village_Medium.01") {
       if (visitedvillage == false){//when the main character collides, it checks if they have already visited the village recently, if they have (true) it will not fire and nothing happens, preventing an endless loop of opening the menu each time you close it once you collide with the village.
        mediumvillagescreentoggle = true;//toggles the village menu
       	visitedvillage = true;
       }
    }
}

function OnGUI() {
	if (mediumvillagescreentoggle == true) {
		GUI.Box(Rect(110,10,400,300),"Medium Village");
	}
}

I did not test the code but i hope it works.