Random.Range HELP!!!

I’m having a problem in javascript and I am still sort of a beginner. I am trying to use Random.Range to make something happen randomly, I am trying to set an int between 0, and 10, but I can’t seem to get it right, any advice?
Here is my code:

var chance = int(UnityEngine.Random.Range(0, 10));

I get the error: BCE0024: The type ‘int’ does not have a visible constructor that matches the argument list ‘(int)’.

Any help would be greatly appreciated!

Don’t use int - Random.Range(0, 10) already returns an integer because the parameters are assumed to be integers. Actually, this function will return an integer between 0 and 9 (the last limit isn’t included in the range in the integer version):

var chance = Random.Range(0, 10);


In Javascript, you cannot call int. It is a type, not a function. But you can cast to it:

randomInt as int

You can also use the Javascript function parseInt to convert to an integer.


Hope this helps,