Index out of bound when trying to select a character

I am having a small error here while trying to access a car in the character selection script I did whatever i could but could not solve it can anyone please help me
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class CarSelector : MonoBehaviour
{
//Made gameobject of the character list
private GameObject characterList;
private int index;

private void Start()
{
    index = PlayerPrefs.GetInt("Character Selection");
    //added count to the child objects of the character list
    characterList = new GameObject[transform.childCount];

    //got the first character in the list
    for (int i = 0; i < transform.childCount; i++)
    {
        characterList *= transform.GetChild(i).gameObject;*

}

//disabled the inactive child characters
foreach(GameObject go in characterList)
go.SetActive(false);
//toggle on the first character
if (characterList[index])
characterList[index].SetActive(true);

}

What you have is an off by one error:


Basically you are trying access something outside of the bounds of your array. i.e. Say your array is 5 items long and you do myArray[5], essentially asking for the 6th item in it. You will get that error.


I hope that makes it pretty obvious which two lines of code are probably causing the problem.