Script not working (Java script)

So, I need some help with my script. I am working on an item spawn script which randomly generates a number between 0 and 20. However, whenever I try and play it gives me this error :

 MissingMethodException: UnityEngine.Mathf.Random
    Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher ()

Code :

var Crisps : GameObject;
var Water : GameObject;
var Beets : GameObject;
var Cola : GameObject;
var Nuka : GameObject;
var Anime : GameObject;
var Pepsi : GameObject;

function Start(){
	 
	var random = Mathf.Floor(Mathf.Random() *20);
		if(random.Equals(0)){
			Instantiate(Crisps, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		if(random.Equals(3)){
			Instantiate(Water, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		if(random.Equals(5)){
			Instantiate(Beets, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		if(random.Equals(6)){
			Instantiate(Cola, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		if(random.Equals(9)){
			Instantiate(Nuka, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		if(random.Equals(16)){
			Instantiate(Anime, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		if(random.Equals(19)){
			Instantiate(Pepsi, this.gameObject.transform.position, this.gameObject.transform.rotation);
		}
		
}	

So, I have also tried another way I have done it using different Math

Code

Now: var random = Mathf.Floor(Mathf.Random() *20);
(Gives error as above, doesn’t spawn)

Before: var random = Random.RandomRange(0, 20);
(No error, only spawns 1 item out of the 7 and only in one place)

There is no Mathf.Random. There also isn’t any Random.RandomRange (or rather it’s obsolete). As you can see in the docs (open the scripting docs and type “random” in the search box), you should use Random.Range. Since you’re only checking for 7 possibilities out of 20, naturally that can’t work. Presumably you want to check for ranges, not individual values? You’d need to use >=, such as:

if (random >= 19) ...
else if (random >= 16) ...
else if (random >= 9) ...
...

However it would be a better idea to use arrays instead of hard-coding all these if/else statements. Note that using “Equals” in this case is not really correct; use == to compare numeric values.

Change your random part to this

 var random = Random.Range(0, 21);

You should be using Random.Range and putting the range in. Min is inclusive, max is exclusive per here:

This will return a whole number as well so you can omit the mathf.floor as well.