Errors with Random Instantiate Script(Solved)

I’m trying to make a simple script to randomly pick one of 3 game objects (prefabs) and instantiate the chosen one adjacent to the object the script is attached.

using UnityEngine;
using System.Collections;

public class SpawnNextSection : MonoBehaviour
{
	public Transform[] nextSection;


	void OnTriggerEnter(Collider other)
	{
		int randomSection = Random.Range(0,nextSection.Length);

		if (other.tag == "Player")
		{
			Vector3 spawnPosition = transform.position + new Vector3 (0, 0, 4);
			Quaternion spawnRotation = Quaternion.identity;
			Instantiate (randomSection, spawnPosition, spawnRotation);
		}
	}

	
}

unfortunately I’m getting some errors -

Assets/Procedural/SpawnNextSection.cs(17,25): error CS1502: The best overloaded method match for `UnityEngine.Object.Instantiate(UnityEngine.Object, UnityEngine.Vector3, UnityEngine.Quaternion)’ has some invalid arguments.

and

Assets/Procedural/SpawnNextSection.cs(17,25): error CS1503: Argument #1' cannot convert int’ expression to type `UnityEngine.Object’

A little help here would be greatly appreciated guys

???

You’re passing “randomSection” as the first parameter of Instantiate() which expects a unity Object.

I believe you meant to write:

Instantiate (nextSection[randomSection], spawnPosition, spawnRotation);

Should be simple

Replace:
Instantiate (randomSection, spawnPosition, spawnRotation);

with

Instantiate (nextSection[randomSection], spawnPosition, spawnRotation);