Cannot cast from source type to destination type

Can someone pleas tell me why I’m getting the above error with the below script please.

Thank you.

#pragma strict

var EmptyInScene : GameObject;
var weapons : GameObject[] = new GameObject[4]; // Array of Weapons
private var curWeapon : GameObject;



function Start () {

       
}

function Update () {

if (Input.GetKeyDown("1")) ChangeWeapon(0);
if (Input.GetKeyDown("2")) ChangeWeapon(1);

}

function ChangeWeapon(weapon:int){

if(curWeapon){
 Destroy(curWeapon);
 }
 
 var NewObject : GameObject = Instantiate(weapons[curWeapon], EmptyInScene.transform.position, EmptyInScene.transform.rotation);
 NewObject.transform.parent = EmptyInScene.transform;

}

curWeapon is of type game object.

You need an integer for your weapons index in the instantiation.

I guess weapon (the parameter) was meant here.