Load a level when requirements are met

I’m currently trying to load a scene once the user clicks the button on the top right hand side of the screen. I’m trying to get it to check if the amount of credits they have is enough and if so, progress to the next scene and if not close the text. I’m a newbie at coding and so need alot of help and laymen terms . please help :slight_smile: heres my current code in Java Script: Master is the name of the script that contains the value I want to check.

var Credits: Master;
var float amountCredits;

var offsetX: float = 40;
var offsetY: float = 40;
var sizeX: float = 100;
var sizeY: float = 40;

function Update(){

		if (amountCredits.Credits > 15)
			Application.LoadLevel ("1");


			GUI.Box (Rect (offsetX, offsetY, sizeX, sizeY),"You have insufficiant credits");

This is my method:
First: Make sure that master.js looks like this:

static var credits = 0;

Then use Master.credits
Use this method:

#pragma strict
var no = false;
 var yes = false;
 function OnGUI(){
     if (GUI.Button(Rect(10,10,300,50), "Do I have enough credits?")){
			if (Master.credits > 14){//Keep one below requiored number of credits
     yes = true;
     no = true; 
     if (yes == true){
      GUI.Label (Rect (10, 300, 400, 20), "You DO have enough credits!");
   if (no == true){
   GUI.Label (Rect (10, 300, 400, 20), "You have insufficient credits!");

Hope it helps! Keep on learning!