Hi, I am getting this error when trying to instantiate a gameobject from an array. I have declared the array public GameObject prizeArr; and added the prefabs to the array in the inspector.
On void Start(), Print(prizeArr.Length) prints 4, however when the collider is triggered and calls the method I get Print(prizeArr.Length) printing 0 and the error ‘IndexOutOfRangeException: Array index is out of range.’
please refer to screenshots and any help is appreciated.

Unity random range can return your Array lenght as a value take care of this.
(prizzArr.Lenght -1)
the float variant is inclusive and can return the max value given, the int variant is exclusive and cannot return the max value (specifically so you can call it for random array selection without faffing around)…
https://docs.unity3d.com/ScriptReference/Random.Range.html
whoops didnt saw that xD, too much time on unreal…
Have you saved chagnes to GoalArea.cs? The log shows lthe error on line 359 yet that line is commented out. You are using random.range correctly and unless you have more than one instance of that array, you shouldn’t get an error.