Show Score When finished the game

I currently have a game where when you collide into an object it updates the score

When I get to the door to end the game it will switch to the Win Screen but I want to show my score on the Win Screen. How would I do this??

Here is my code

var vase : String = "Bob";
private var scoreText:GUIText;
private var score:int;
public var level:String;
public var sound4: AudioClip;
public var Metal_Impact_Hollow: AudioClip;


function Start () 
{
//intialize our variables listed

	score = 0;
	
	scoreText = GameObject.Find("GUI_Score").GetComponent(GUIText);
	//call update function to update text
	UpdateScoreText();

}



function UpdateScoreText()
{
	//update the GUI Text on screen
	scoreText.text = "Score: " + score;
}





function OnCollisionEnter(c:Collision)
{
    if (c.gameObject.name == "vase" )
    {
        Destroy(c.gameObject); // destroys the thing this script bumped into
        score += 100;
		UpdateScoreText();
	}
	
	
    if (c.gameObject.name == "shield" )
    {
        Destroy(c.gameObject); // destroys the thing this script bumped into
        score += 500;
		UpdateScoreText();
	}
	
	  if (c.gameObject.name == "foxmask2" )
    {
        Destroy(c.gameObject); // destroys the thing this script bumped into
        score += 900;
		UpdateScoreText();
	}
	
	
	  if (c.gameObject.name == "boots2" )
    {
        Destroy(c.gameObject); // destroys the thing this script bumped into
        score += 200;
		UpdateScoreText();
	}
	
	  if (c.gameObject.name == "backdoor" )
    {
      
		Application.LoadLevel("WinScreen");
	}
	
	  if (c.gameObject.name == "Cube" )
    {
      
		Application.LoadLevel("LoseScreen");
	}
	
	  if (c.gameObject.name == "Cube2" )
    {
      
		Application.LoadLevel("LoseScreen");
	}

	
}

Why load level? Just use a GUI label that will display your score var.

To display score in another screen u can use database (eg. SQLITE) or u can write the score on a file and read when u need.

Best not to write such information to a database, there’s no need. Just make your variable public so it’s able to be used in all scripts / functions.

As said by Artaani, I would recommend using a GUI to display your score, whether you load a new level or not.

This is C# code. I am not good in Unity with Javascript.

bool isGameWin = false;
int score = 0;
void OnGUI()
{
if(isGameWin)
{
GUI.Label (new Rect (10, 10, 100, 20), "Total Score: " + score);
if(GUI.Button(new Rect(40, 40, 100, 30), "Load Next Level") )
{
isGameWin = false;
//Do something here
}
}
}

void OnCollisionEnter(Collision c)
{
    if (c.gameObject.name == "backdoor" )
{
isGameWin = true;
}
}

Hope this Helps…

What exactly would happen If I just used a GUI label without loading a level? Would it just show my score on screen in the middle of gameplay? or would it show on a different screen somehow? I want my score to show on my WinScreen after I’m done collecting the objects

I played around with the GUI label and put this at the bottom of my code

function OnGUI ()
{
GUI.Box (Rect(Screen.width - 200,Screen.height-35,200,80),“Total Score:” + score);
}

that updated the score on the game play screen but I want it show on my Win Screen level when my character hits the back door. I think I need to put an “if statement” somewhere but have no idea where.

and MicroEyez I tried using your code but it keeps telling me to put semi colons where there already are semi colons. Plus your using C#.

anybody?? assignment is due today and I wanna pass this program to get my Advanced Diplmoa and become a character modeller