How to substitute an array for a public Gameobject?

Hello, I’m trying to get a weapon array to work so I can have my player shoot different prefabs. If I keep the public field as one prefab it works fine, I tried to add the array and it’s not working. Can someone point me in the right direction? Thanks (and by the way I realize there is currently nothing to change the currentWeapon int from 0 to 1, but I’ve been doing it manually to test it)!

// Launch projectile
public class PlayerWeaponScript : MonoBehaviour
{
	public Transform [] shotPrefab;// Projectile prefab for shooting
	public float shootingRate = 0.25f;// Cooldown in seconds between two shots
	private float shootCooldown;
	private int currentWeapon = 0;

	void Start()
	{
			shootCooldown = 0f;
	

			}
		void Update()
	{
		if (shootCooldown > 0)
		{
			shootCooldown -= Time.deltaTime;
		}
	}
	//Shooting from another script
	// Create a new projectile if possible
	public void Attack(bool isEnemy) {
				if (CanAttack) {
						if (currentWeapon == 0) {
								int shotIndex = 0;
						} else if (currentWeapon == 1) {
								int shotIndex = 1;
								shootCooldown = shootingRate;
								var shotTransform = Instantiate (shotPrefab [shotIndex]) as Transform;// Create a new shot
								shotTransform.position = transform.position;// Assign position
								ShotScript shot = shotTransform.gameObject.GetComponent<ShotScript> ();
								if (shot != null) {
										shot.isEnemyShot = isEnemy;
										gameObject.tag = "Enemy";
								}
								// Make the weapon shot always toward
								EnemyMoveScript move = shotTransform.gameObject.GetComponent<EnemyMoveScript> ();
								if (move != null) {
										move.direction = this.transform.right; // towards in 2D space is the right of the sprite
			
								}
						}
				}
		}
		
		public bool CanAttack// Is the weapon ready to create a new projectile?
	{
		get
		{
		return shootCooldown <= 0f;
		}
	}
}

Looks like you need another } to close off the else if on line 29. Currently you are only firing if the second weapon is selected. A nested if might be better. Pseudo code

public void Attack(bool isEnemy) {
     if (CanAttack){
         int shotIndex;
         if (currentWeapon == 0) {
             shotIndex = 0;
         } else if (currentWeapon == 1) {
             shotIndex = 1;
         }
         // Do attack as written
     }
}

Note: If currentWeapon is always going to map directly onto shotIndex then there is no need to use shotIndex.

Edit: Moved scope of shotIndex up a level. See comments.

Here is the code that finally worked for me (still changing the currentWeapon int manually), based on major help from BoredMormon and Bunny83:

using UnityEngine;

// Launch projectile
public class PlayerWeaponScript : MonoBehaviour
{
	public Transform [] shotPrefab;// Projectile prefab for shooting
	public float shootingRate = 0.25f;// Cooldown in seconds between two shots
	private float shootCooldown;
	private int currentWeapon = 0;

	void Start()
	{
			shootCooldown = 0f;
	}
		void Update()
	{
		if (shootCooldown > 0)
		{
			shootCooldown -= Time.deltaTime;
		}
	}
	//Shooting from another script
	// Create a new projectile if possible
	public void Attack(bool isEnemy) {
		if (CanAttack){
			if (currentWeapon == 0) {
			} else if (currentWeapon == 1) {
			}
			shootCooldown = shootingRate;
			var shotTransform = Instantiate (shotPrefab [currentWeapon]) as Transform;// Create a new shot
								shotTransform.position = transform.position;// Assign position
								ShotScript shot = shotTransform.gameObject.GetComponent<ShotScript> ();
								if (shot != null) {
										shot.isEnemyShot = isEnemy;
										gameObject.tag = "Enemy";
								}
								// Make the weapon shot always toward
								EnemyMoveScript move = shotTransform.gameObject.GetComponent<EnemyMoveScript> ();
								if (move != null) {
										move.direction = this.transform.right; // towards in 2D space is the right of the sprite
			
								}
						}
				}
		public bool CanAttack// Is the weapon ready to create a new projectile?
	{
		get
		{
		return shootCooldown <= 0f;
		}
	}
}