Check if a guiText = a number?

The game I’m creating requires the player to collect a certain amount of objects each level, I want an endgame script that basically loads the score screen. How can I do this? When the player collects the objects they are displayed in a guiText, but I can’t use

var object : guiText;

function Update(){
if(object.guiText.text = 2){
Application.loadlevel(0);
}
}

That’s probably wrong but it was just a rough idea of what I was trying, it needs me to convert the string to int but I’m not sure how?

if you are collecting a certain number of objects, then you should be keeping track of that as an int already… then for the GUIText you would convert the int to a string. (You would never need to go from string to int in this case.) In order to keep track of the number of items collected it would need to be stored this way anyway. Here’s a similar example:

http://answers.unity3d.com/questions/331921/collestion-of-objects.html

in this case, itemsCollected would be the int you are watching:

function Update(){
 if(itemsCollected >= 2){
 Application.LoadLevel(0); }
 }

(for example)

(if you have an existing script to collect items, post it and I’ll help fix it…)

you can declare a char by placing it in single quotes or a string by placing it it double quotes

be aware

char = one character
a character is basically a single keystroke, any key you can press is a character. one letter, one number, or symbols like !@#$.

string = a collection of characters

'a' is a character
'1' is a character

"a" is a string
"1" is a string
"12" is a string
12 is a int
'12' is illegal, its two characters and a character is only one.

writing out the actual value is a literal string
if you have say a string variable like

string my_own_string;

and its equal to only one character like

my_own_string = ‘a’;

and you’d like to convert it to a character tehre is a function for that

my_own_string.tochar();

hope taht helps mark as answered!