GameObject or Transform?

script work when I put “GameObject[ ]”, but I want to put “Transform[ ]”

public Transform[] weapons;

    void Start(){
        SelectWeapon(0);
    }
   
    void Update(){
        if(Input.GetKeyDown("1")) SelectWeapon(0);
        if(Input.GetKeyDown("2")) SelectWeapon(1);
    }
   
    void SelectWeapon(int index){
        foreach(Transform obj in weapons) obj.SetActive(false);
        weapons[index].SetActive(true);
    }

[Code]

try changing line 15
weapons[index].SetActive(true);
to
weapons[index].gameObject.SetActive(true);