Unable to get Random.Range(0, 4) to work

I’m not able to get Random.Range(0, 4) to work. This is how I’m using it:

int number = Random.Range(0, 4);

I’ve read most of the answers currently on the unity forums and nothing seems to work, Random.Range(0, 4) is always returning a 0 or a 1.

The weirdest part of this all is that I’ve used Random.Range() before with no issue and I didn’t have a different syntax at all.

I’ve tried changing my int number to float number, I’ve initialized number to zero before assigning a Random.Range() value to it. I have no idea why it won’t return anything other than 0 or 1 (and those are almost 100 percent alternating each time).

Any help would be greatly appreciated.

Do you see any error message in the Console window? Perhaps it’s an ambiguity between System.Random and UnityEngine.Random?

Zero error messages in the console. My code is something like this. Its so simple that I can’t imagine why it isn’t working.

gist:f1bdbe0c068d00039fe00d378e176464

I recommend to learn how to debug code, as this allows to identify and fix these kind of issues.
https://unity3d.com/learn/tutorials/topics/scripting/debugging-unity-games-visual-studio

https://discussions.unity.com/t/481379