Disabling children and comparing them

i have been trying for a few hours now to get this code to work and looking in other parts of the community. I am trying to finish my inventory system the last bit is equipping items then and then disabling all the other weapons and then enabling the weapon,

The error i am getting is: UnityException: Transform child out of bounds
Weapons_.Update () (at Assets/Weapons_.js:11)

2.var Swordinv : GameObject;
3.var Swordobj : GameObject;
4.var Slot : GameObject;
5.var Char : GameObject;

function Start () {

}

function Update () {
if (Slot.transform.GetChild(0) == Swordinv) {
Swordobj.active = true;
}
else if (Slot.transform.GetChild(0) == Swordinv) {
Swordobj.active = false;
}

2.var Swordinv : GameObject;

3.var Swordobj : GameObject;

4.var Slot : GameObject;

5.var Char : GameObject;

function Start () {

}

function Update () {

if (Slot.transform.GetChild(0) == Swordinv) {

Swordobj.active = true;

}

else if (Slot.transform.GetChild(0) == Swordinv) {

Swordobj.active = false;

}

Sorry i did not know how badly the code would be posted