GetComponent is not member of Object?

I’m trying to make an inventory system and I want to show the description of a GameObject when it’s clicked on. The code goes like:

if(GUILayout.Button(inventoryNames[x].ToString(),GUILayout.Width(100), GUILayout.Height(50))){
    GUI.Box(Rect(50, 100, 50, 100), inventory[x].GetComponent(itemScript).description); //PROBLEM LINE
}

What type of array/list is inventory?

try this

inventory[x].gameObject.GetComponent<itemScript>().description

Yes, GetComponent isn’t part of Object - Object is a variant type, usually assumed by Unity when the compiler can’t infer the correct type, or in elements of the Array class. Is inventory[] an Array()? If so, assign the element to a variable of the right type before using GetComponent:

if(GUILayout.Button(inventoryNames[x].ToString(),GUILayout.Width(100), GUILayout.Height(50))){
    var item: GameObject = inventory[x]; // assuming that inventory contains GameObjects
    GUI.Box(Rect(50, 100, 50, 100), item.GetComponent(itemScript).description); //PROBLEM LINE
}