When I call a function it should call for an int but I want the int to be circled through a few int’s so it’s always different, example:

I call for the function, the int I want is 2 but next time it’s 4 and then 6, but when it reaches 10 it goes back to 2 but I want to use this for the y axis of an instantiate, how can I do this efficiently and neat? without adding too much code

I hope I explained good enough what I want.

		Instantiate(object, new Vector3(1, y, 1), transform.rotation);

Try something like this

for(var y: int = 2; y < (how many you need); y +=2){

    Instantiate(object, new Vector3(1, y % 10, 1), transform.rotation);

}

The only thing with it is if y is a multiple of 10, the result will be 0.

EDIT:

An alternative would be (if the order doesn’t matter):

for(var y: int = 0; y < (how many you need); y +=2){

    Instantiate(object, new Vector3(1, -y % 10 + 10, 1), transform.rotation);

}

private int nextInt = -1;

int GetNextInt()
{
    nextInt = ++nextInt % 5;
    return (nextInt + 1) * 2;
}

This will give you exactly that secuence of numbers. Use it like this:

Instantiate(object, new Vector3(1, GetNextInt(), 1), transform.rotation);