Script stops working when switching to Android

i have a script that types a GUI text out with sound like a computer and it works perfectly on PC but when i try to distribute it to an .apk for android it gives me

Assets/Scripts/TYPE TEXT.js(13,33): BCE0019: ‘ToCharArray’ is not a member of ‘Object’.

i know it might be a simple solution but i cant seem to fix it…
can someone please help me??

here is the script…

var letterPause = 0.2;
var sound : AudioClip;
 
private var word;
 
function Start () {
	word = guiText.text;
	guiText.text = "";
	TypeText ();
}
 
function TypeText () {
	for (var letter in word.ToCharArray()) {
		guiText.text += letter;
		if (sound)
			audio.PlayOneShot(sound);
		yield WaitForSeconds (letterPause);
	}		
}

You need to specify the type of the variable ‘word’. Since its a string i would simple declare the type as String or use var word = “”; It is a very bad habit to not define the type of your variables, even something straight-forward like this.

As the error states, type object or Object do not have a method ToCharArray(). String however does, explicitly stating the variable as string will solve the issue.