InvokeRepeating with a variable?

I was wondering if you could possibly use a variable to make InvokeRepeating repeat a random time?
for example:

var randomNumber : float =Random.Range(3, 10);

function Start()
{
InvokeRepeating("Test", 1, randomNumber);
}

function Test()
{
print("Success!");
}

Or perhaps I should do this:

function Update()
{

yield WaitForSeconds(random);

var randomNumber : float = Random.Range(3, 10);

}

If the goal is to have InvokeRepeating use a different length of time whenever it repeats, then no, that’s not possible using InvokeRepeating. Instead you can use a coroutine. (But not like your second example, which can’t work since Update can never be a coroutine. Just leave Update out of it and use a coroutine.)

I figured out what I was trying to accomplish: random generation of a number once every X seconds, for decision making.
Heres the code:

    var rand;
    
    function Start()
    {
    InvokeRepeating("RandomRanger", 0, 1.5);
    //sets function to repeat once every 1.5 seconds starting immediately
    }
    
    function RandomRanger()
    {
    var it = Random.Range(1, 5);
    rand = it;
    //makes random number
    }
    
    function Update(){
    print (rand);
    }