title: Keep on receiving an argument of of range exception when there shouldn't be one?
body: <p>I recently tried to change the code of one of my scripts of a game I'm working on in Unity and I keep on getting an argument out of range exception error message thrown at me for the <code>ColouredBallPositions[x - 1]</code> values I am adding in my for loop. However, the argument for this shouldn't be out of range.</p>
  
  <p>This is the exact error message as displayed in the unity console:</p>
  
  <blockquote>
    <p>ArgumentOutOfRangeException: Index was out of range. Must be
    non-negative and less than the size of the collection.</p>
    
    <p>Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException
    (System.ExceptionArgument argument, System.ExceptionResource resource)
    (at &lt;23c160f925be47d7a4fd083a3a62c920>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at
    &lt;23c160f925be47d7a4fd083a3a62c920>:0)
    System.Collections.Generic.List`1[T].set_Item (System.Int32 index, T
    value) (at &lt;23c160f925be47d7a4fd083a3a62c920>:0) SpawnPoint.Start ()
    (at Assets/SpawnPoint.cs:43)</p>
  </blockquote>
  
  <p>Ive tried to look through StackOverflow and the internet for answers to why I might receive this error message but I haven't found an answer to why my code would produce this error message.</p>
  
  <pre><code>    using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
  
      public class SpawnPoint : MonoBehaviour
      {
  
          public Transform SpawnPoints;
          List&lt;float&gt; StarPositions = new List&lt;float&gt;();
          List&lt;float&gt; ColouredBallPositions = new List&lt;float&gt;();
          List&lt;float&gt; ColouredBallRanges = new List&lt;float&gt;();
          int Interact, randomSpawnPoint;
          public static bool spawnAllowed;
          ObjectPooler objectPooler;
          int index = 1;
  
  
          public void Start()
          {
              objectPooler = ObjectPooler.Instance;
  
              if (ScoreScript.scoreValue &lt; 5)
              {
  
                  Vector2 pos =                         
               Camera.main.WorldToViewportPoint(transform.position);
  
  
                  for (int x = 1; x &lt; 5; x++) // Change this to get rid of the need to generate spawnpoints
          {
              //Vector3 SpawnPos = spawnPoints[d].position;
              int NrSpawnpoints = 4;
              int NrSpaces = NrSpawnpoints + 1;
              double Xlegnth = 1.0;
              double spawnPosX = x * Xlegnth / NrSpaces;
              pos.x = (float)spawnPosX;
              pos.y = 1.3f;
              ColouredBallPositions[x - 1] = (float)spawnPosX;
              Vector2 Posi = Camera.main.ViewportToWorldPoint(pos);
              Instantiate(SpawnPoints, Posi, Quaternion.identity);
  
             // Debug.Log(Posi);
  
          }
  
          spawnAllowed = true;
          InvokeRepeating("SpawnAInteract", 0f, 1f);
      }
  
  }
  </code></pre>
  
  <p>No exception is thrown</p>