ArgumentException: RandomRangeInt can only be called from the main thread.

I am getting this compile error when I try and run this script: RandomRangeInt can only be called from the main thread.

private var random = Random.Range(0, 4);

function Update () 
{
	print (random);
}

Any Idea on how to solve this??

–Thanks!

Yeah, don’t try to run that Random command on variable init, do it this way:

private var random : int;

function Start () 
{
     random = Random.Range(0, 4);
}

function Update () 
{
    print (random);
}

If you want it to continuously make new random numbers, put that line from Start into Update also.