Not showing GUI.SelectionGrid!

Hello guys. I’ve been programming this game and lately i was working on Score Grid. Everything seems ok, but the GUI.Window not showing at all, or without SelectionGrid. It seems i can’t figure it out by myself, so i need your help!

Here’s the code:

#pragma strict

var Vardas : String; //vardas stands for Name (this one is for the player to type by himself))
var Vardas1 : String[]; //this one is for Top 4 to be saved in PlayerPrefs

var Laikas : int; //laikas stands for Time
var Laikas1 : int[];

var selGridInt : int = 0;
var selStrings : String[] = [Vardas1[0], Laikas1[0], Vardas1[1], Laikas1[1]]; //i made this like in unity docs
var selGridInt2 : int = 1;
var selStrings2 : String[] = [Vardas1[2], Laikas1[2], Vardas1[3], Laikas1[3]];

//------------------ This part is not important -----------------
var timer : float = 13;
var MainMenu : Rect = Rect(10, 10, Screen.width, Screen.height);

static var completed : boolean = false;

private var paused : boolean = false;
private var A : boolean = false;
private var B : boolean = false;



function Start() {
//-------------------------------------------
//i get all the prefs
	Vardas1[0] = PlayerPrefs.GetString("Vardas1");
	Vardas1[1] = PlayerPrefs.GetString("Vardas2");
	Vardas1[2] = PlayerPrefs.GetString("Vardas3");
	Vardas1[3] = PlayerPrefs.GetString("Vardas4");
	Laikas1[0] = PlayerPrefs.GetInt("Laikas1");
	Laikas1[1] = PlayerPrefs.GetInt("Laikas2");
	Laikas1[2] = PlayerPrefs.GetInt("Laikas3");
	Laikas1[3] = PlayerPrefs.GetInt("Laikas4");
//-------------------------------------------
}


//------------------ This part is not important -----------------
//laiko skaiciavimas
function Update () {
Screen.showCursor = false;
	if(timer > 0)
  		timer -= Time.deltaTime;
  	if(timer <= 0) {
		completed = true;
		}
		
		
//--------------------
//pause menu

	if(paused) {
		Time.timeScale = 0;
		Screen.showCursor = true;
		Screen.lockCursor = false;
	}
	
	else {
		Time.timeScale = 1;
		Screen.showCursor = false;
		Screen.lockCursor = true;
	}
	
	if(completed == true)
		paused = true;
		
}

//-------------------------------first for cycle is for finding the place for our player to be in the Top 4
//lenteles generavimas
private var kelintas : int;
	if(A) {
		for(var i = 0; i < 4; i++) //radimas rezultato vietos lenteleje
			if(Laikas1[i] > Laikas)
				kelintas++;
		//---- when whe have place, put it in there
		//iterpia i masyva kelintas vietoje reiksme
		for(var c = 4; c > kelintas; c--) {
			 Laikas1[c] = Laikas1[c-1];
			 Vardas1[c] = Vardas1[c-1];
		}
		Laikas1[kelintas] = Laikas;
		Vardas1[kelintas] = Vardas;
	
		B = true; //and after all of that, show the Top 4 window
	}


//---------------------
//GUI funkcijos
function OnGUI(){
	if(paused  A == false) { //if paused then show the Gui to enter Name
		Scoreenter();
	}
	if(A  B) { //if the table has been generated then show the table
//one more problem is that the first Rect parametres doesnt change anything, it still shows gui almost from the middle of the screen no matter what
		GUI.Window(0, MainMenu, Lentele, "TOP 4 SCORES");
	}
}


function Scoreenter() {
	GUI.Box(Rect(Screen.width * 0.4f,Screen.height * 0.5f,200,50), " Type in your name: ");
	Vardas = GUI.TextField (Rect (Screen.width * 0.4f, Screen.height * 0.55f, 200, 20), Vardas, 20);
	if(GUILayout.Button("Continue",  GUILayout.Width(Screen.width), GUILayout.Height(Screen.height * 0.5f))){
	A = true;
	}
}
	
//--------------The problem is here--------------
//i need 8 buttons (4 for names and 4 for times)(why buttons not text box? because it's easyer)
function Lentele(){
	selGridInt = GUI.SelectionGrid (Rect (10, 20, Screen.width/5, Screen.height/5), selGridInt, selStrings, 2);
	selGridInt2 = GUI.SelectionGrid (Rect (10, 20, Screen.width/2.5, Screen.height/2.5), selGridInt2, selStrings2, 2);
}

Thank you for any help.

B is never true
Doesn’t look like the block 75-89 is in any function, so isn’t executed.

that was my mistake, but after fixing that, it still doesn’t show anything: here’s the fixed code

var Vardas : String; //name
private var Vardas1 : String[]; //top 4 names

var Laikas : int = level2tele.laikas; //i get time from other script
private var Laikas1 : int[] = [500, 600, 800, 900]; //top4 times

var selGridInt : int = 0;
var selStrings : String[] = ["this", "is" , "frustrating", "omg"]; //strings and ints to be shown
var selGridInt2 : int = 1;
var selStrings2 : String[] = [Vardas1[2], Laikas1[2], Vardas1[3], Laikas1[3]];

var timer : float = 13;
var MainMenu : Rect = Rect(10, 10, Screen.width, Screen.height);

static var completed : boolean = false;

private var paused : boolean = false;
private var A : boolean = false;
private var B : boolean = false;
private var kelintas : int = 1;



function Start() {
//-------------------------------------------
//we get those top 4 scores
	Vardas1[0] = PlayerPrefs.GetString("Vardas1");
	Vardas1[1] = PlayerPrefs.GetString("Vardas2");
	Vardas1[2] = PlayerPrefs.GetString("Vardas3");
	Vardas1[3] = PlayerPrefs.GetString("Vardas4");
	Laikas1[0] = PlayerPrefs.GetInt("Laikas1");
	Laikas1[1] = PlayerPrefs.GetInt("Laikas2");
	Laikas1[2] = PlayerPrefs.GetInt("Laikas3");
	Laikas1[3] = PlayerPrefs.GetInt("Laikas4");
//-------------------------------------------
}


//---------------------
//time counting for gui to be shown
function Update () {
Screen.showCursor = false;
	if(timer > 0)
  		timer -= Time.deltaTime;
  	if(timer <= 0) {
		completed = true;
		}
		
		
//--------------------
//pause menu


	if(completed)
		paused = true;
		
	if(paused) {
		Time.timeScale = 0;
		Screen.showCursor = true;
		Screen.lockCursor = false;
	}
	
	else {
		Time.timeScale = 1;
		Screen.showCursor = false;
		Screen.lockCursor = true;
	}
		
}

//---------------------
//GUI functions
function OnGUI(){
	if(paused  A == false)
		Scoreenter();
	
	
	//-------------------------------
//top 4 generation
	if(A) {
		for(var i = 0; i < 3; i++) //finding in which place our player will be in top 4
			if(Laikas1[i] < Laikas)
				kelintas++;
		//----
		// and puts it in that place
		for(var c = 3; c > kelintas; c--) {
			 Laikas1[c] = Laikas1[c-1];
			 Vardas1[c] = Vardas1[c-1];
		}
		Laikas1[kelintas] = Laikas;
		Vardas1[kelintas] = Vardas;
	
		B = true; //change this so we can show our top4 list, when that list is ready
	}
	
	
	
	if(A  B) {
		GUI.Window(0, MainMenu, Lentele, "TOP 4 SCORES"); //this one is not working, even if i make B and A always true
	}
}


function Scoreenter() { //this function shows everything perfectly
	GUI.Box(Rect(Screen.width * 0.4f,Screen.height * 0.5f,200,50), " Type in your name: ");
	Vardas = GUI.TextField (Rect (Screen.width * 0.4f, Screen.height * 0.55f, 200, 20), Vardas, 20);
	if(GUILayout.Button("Continue",  GUILayout.Width(Screen.width), GUILayout.Height(Screen.height * 0.5f))){
	A = true;
	}
}
	
//but this one is driving me crazy...
//i made this list 2x4, those buttons dont need to do anything. 
function Lentele(){
	selGridInt = GUI.SelectionGrid(Rect (10, 20, Screen.width/5, Screen.height/5), selGridInt, selStrings, 2);
	selGridInt2 = GUI.SelectionGrid (Rect (10, 20, Screen.width/2.5, Screen.height/2.5), selGridInt2, selStrings2, 2);
}

It helps if you post what errors are given by Unity.

Theres still a bunch of things wrong with your script

Line 10:
var selStrings2 : String[ ] = [Vardas1[2], Laikas1[2], Vardas1[3], Laikas1[3]];
(a) It mixes Vardas and Laikas… (b) Im also not sure you can index a property outisde a function (script wouldnt compile when i copied it)

That block (now 80-93) is now executing every frame, so ‘kelintas’ is going to increment very high, giving IndexOutOfRange errors
And i dont think that it correctly moves the existing scores down a place, looks more like it moves them up.