Button not responding correctly

Hi, i’ve been following this tutorial on inventory systems,

I’m having trouble removing them, I can’t even get them to debug anything (regardless whether its the right button thats pressed)

EDIT: This is attached to my main camera of the standard asset character controller
This is my script, although the error I think is somewhere in the drawmywindow function - Thanks
void Update(){
if (Input.GetKeyDown (KeyCode.Escape)) {

	showInventory = !showInventory;

	}

		ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		if (Input.GetButtonDown ("Fire1")) {
			
						if (Physics.Raycast (ray, out hit, 20)) {
				
				for (int i = 0; i < bag.Length; i++) {
					
					if (hit.collider.tag == bag*.id.ToString ()) {*

_ Inventory.Add (bag*);_
_
Destroy (hit.collider.gameObject);_
_
}_
_
}_
_
}_
_
}_
_
pos = transform.position;_
_
pos.x += 20;_
_
} // End update*_

* void OnGUI(){*
* if (showInventory == true) {*
* windowRect = GUI.Window (0, windowRect, DoMyWindow, “Inventory”);*
* }*
* }*

* void DoMyWindow(int windowID) {*
* int y = 20;*
* GUI.DragWindow(new Rect( 0,0,windowLength,20));*

* for(int i = 0; i < Inventory.Count; i++){*
_ if(GUI.Button (new Rect(20, y, 64, 64), Inventory*.icon)){
Debug.Log(“button clicked”);
Instantiate(Inventory.player,pos,transform.rotation);
Inventory.RemoveAt(i);
}
y+=70;
}
}//End DoMyWindow*_

Somehow solved this myself, I placed it on my actual character controller.

This is the adapted code -
void DoMyWindow(int windowID) {
int inventoryLength = 20;
GUI.DragWindow(new Rect( 0,0,windowLength,20));

		for (int i = 0; i < Inventory.Count; i++) {
			GUI.Label(new Rect(100,inventoryLength,100,20), Inventory*.itemName);*

_ GUI.Label(new Rect(100,inventoryLength + 15,100,20), Inventory*.description);*_

_ if(GUI.Button (new Rect (20, inventoryLength, 64, 64), Inventory*.icon)) {
Inventory.RemoveAt(i);
}
inventoryLength += 70;
}
}*_