Multiple Melee Weapons Systems Script HELP

I am having issues with correcting this script and I just can’t figure it out…
Please help :frowning:

The error I get in Unity is…
"
Assets/Scripts/Player Scripts/Weapons.js(11,35): BCE0022: Cannot convert ‘UnityEngine.GameObject’ to ‘int’.
"

#pragma strict

var weapons: GameObject[];
private var curWeapon: GameObject;
 
function ChangeWeapon(weapon:int){
 
  if (curWeapon){
    Destroy(curWeapon);
  }
  curWeapon = Instantiate(weapons[curWeapon],transform.position,transform.rotation);
}
 
function Update(){
 
  if (Input.GetKeyDown("1")) ChangeWeapon(0); 
  if (Input.GetKeyDown("2")) ChangeWeapon(1);
  if (Input.GetKeyDown("3")) ChangeWeapon(2);
}

‘curWeapon’ is a game object. When you do:

weapons[curWeapon]

…you are attempting to use it as an int. I believe you want to do:

weapons[weapon]

…as in:

  curWeapon = Instantiate(weapons[weapon],transform.position,transform.rotation);