[C#] Array out of bounds

I’m trying to make a line of prefabs that spawn next to each other depending on their sprite size. I am however getting a out of bounds error, but I can’t seem to find out why.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Spawner : MonoBehaviour {

    public int numPlat;
    public GameObject[] PlatSpawner;
    public GameObject PlatformToSpawn;
    public Vector2 spawnPosition;
    public Vector2 NextSpawnPosition;
    public SpriteRenderer spriteChosen;
	// Use this for initialization
	void Start () {
        
        Debug.Log("Number" + numPlat);
        spawnStuff();
        

    }
	
	// Update is called once per frame
	void Update () {
	
	}

    private void Awake()
    {

    }

    public void spawnStuff()
    {
        
       
        for (int i = 0; i < numPlat; i++) 
        {
            if (i == 0)
            {
                PlatSpawner[0] = Instantiate(PlatformToSpawn, transform.position, Quaternion.identity) as GameObject;
            }
            if (i >= 1)
            {
                spawnPosition = PlatSpawner*.transform.position.x + new Vector3( spriteChosen.bounds.size.x,0);*

PlatSpawner = Instantiate(PlatformToSpawn, spawnPosition, Quaternion.identity) as GameObject;
Debug.Log(“ds”);
}
}
}

}

what about this simple :

int Nextpos;
Vector3 pos;
public GameObject [] obj;
void Start(){
	for (int i = 0; i < obj.Length; i++) {
		Nextpos ++;
		pos = new Vector3 (transform.position.x + Nextpos, transform.position.y, transform.position.z);
		Instantiate (obj *, pos, transform.rotation);*
  •   }*
    
  • }*
    & just manipulate the object scale size to reduce the gap between objects . & as RakshithAnand said no need to numPlat this way is more dynamic doesn’t mater how many objects you add it will work.