Minor issue with timing of UI popup box(Javascript)

Hello all!

Just for the life of me haven’t been able to figure out what’s wrong with my code (considering I just copied then modified from another object that does the same thing but work correctly). It uses two codes. One to detect when the player is within range, and the other to put up the popup box and then load the level. The level load works correctly, but the box is always there instead of like the other boxes how it comes and goes based on my range to the object. I wasn’t sure if maybe I put it on another object or not, so I deleted the script, it went away, and then I re-did the script only to find it doing it again. Here are my scripts:

Display GUI Script_FlyingGame.js:

var target : Transform;

function Update (){
var other = gameObject.GetComponent(“GUI Style Script_Flying Game”);

if(Vector3.Distance(target.position, transform.position) > 5) {
other.enabled = false;
}
else if(Vector3.Distance(target.position, transform.position) < 5) {
other.enabled = true;

}
}

GUI Style Script_FlyingGame.js:

var target : Transform;

function Update (){
var other = gameObject.GetComponent(“GUI Style Script_Flying Game”);
}

function OnGUI() {
//Make a background box
GUI.Box (Rect (400,400,300,90), “Do you want to play the Flying Game?”);

//Make the first button. If it is pressed, Application.Loadlevel(“Flying Game”) will be executed
if(GUI.Button (Rect(450,450,80,20), “Yes”)) {
Loading_Screen.LoadingScreenOn = true;
Application.LoadLevel(“Flying Game 2”);
}
if(GUI.Button (Rect(600,450,80,20), “No”)){
“GUI Style Script_Flying Game”.enabled = false;

}
}

I really appreciate the help. I try to fix things when I can, but it’s been about a week of trying to find this problem to no avail.

Edited to include script names for clarity

I am inexperienced in the string version og GetComponent,but can this really be a valid component name? “UI Style Script_Flying Game”

Besides that, your distance script will only deactivate/activate the “UI Style Script_Flying Game” component, not sure if that is your script with the box as you didnt mentioned this clearly.

I added the script names to their respective scripts to make it clearer(sorry about that). I’m really confused because this exact script minus the “Flying Game” part is exactly what I use for my other “portals”.

UPDATE
I got it to go away by correcting the name to FlyingGame without a space, but now when approaching it won’t turn on…

UPDATE
Fixed, just had some of them mixed up as to what they were attached to on that last trial. Thanks for taking a look at it for me.