I am new to unity and my code below gives me the error; Array index is out of range. Could someone explain to me why this happens and the possible solutions. Thanks! I could post any other things necessary.
Inspector:

Error
:
Code:
using UnityEngine;
using System.Collections;
public class SpawnPrefab : MonoBehaviour {
public GameObject[] enemies;
public int amount;
private Vector3 spawnPoint;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
enemies = GameObject.FindGameObjectsWithTag ("Apple");
amount = enemies.Length;
if (amount != 3) {
InvokeRepeating ("spawnEnemy", 5, 10f);
}
}
void spawnEnemy() {
spawnPoint.x = Random.Range (9, 6);
spawnPoint.y = Random.Range (9, 6);
Instantiate(enemies [UnityEngine.Random.Range(0, enemies.Length - 1)], spawnPoint, Quaternion.identity);
CancelInvoke ();
}
}