Help with InvokeRepeating IndexoutofRangeExceptio

First off, the main problem I have is for some reason InvokeRepeating does not work.

InvokeRepeating("check_messages",2,10);

Which basically says run check_messages in 2 seconds every ten seconds.

Now where do I place this line of code for it to correctly work? because right now I have it under start and have tried it out of a function as well and no go.

The code in check_messages does work, I have tested it other ways.


My second problem is that I have a variable that gathers the www.data from a php script. Then it is Split to separate lines in an array[0]. When I set the updated prefs to the array I get the exception.

function setPrefs(){

var form2 =  new WWWForm(); 
form2.AddField("username", PlayerPrefs.GetString("Player Name")); 
var w = new WWW(phpscript2, form2); 
yield w; 
returnlines = w.data;
userInfo = returnlines.Split("\t"[0]);
PlayerPrefs.SetInt("Attack", parseInt(userInfo[2]));
PlayerPrefs.SetInt("Defense", parseInt(userInfo[3]));
PlayerPrefs.SetInt("Vitality", parseInt(userInfo[4]));
PlayerPrefs.SetInt("Health", parseInt(userInfo[5]));
PlayerPrefs.SetInt("Exp", parseInt(userInfo[6]));
PlayerPrefs.SetInt("lvl", parseInt(userInfo[7]));

}

I would really appreciate if someone could point me in the right direction!

Wherever you want it to be invoked from. A Start function is fine.

What’s generating the exception exactly?

–Eric

I fixed the exception in the script. It was a silly error.

I am still having a problem with invoking.

InvokeRepeating(“scriptName”,2,5);

My script connects to a php script to update player prefs from a mysql database.

Currently I have an update button that runs the same exact script when pressed and it works, but when I just use InvokeRepeating, it never runs… I don’t understand why? any ideas.

should it be written like this?
InvokeRepeating(scriptname(),2,5);

Invoke only runs functions, not scripts.

–Eric

My apologizes, I was in a rush at typed the wrong thing. It is a function, not a script.