C# Check if parent's script's GameObject variable equals GameObject

I’m trying to check if a parent’s script’s gameobject variable equals a gameobject. Void OnMouseDown works fine but the if statement never equals true for some reason. Void OnGUI is check every frame like update and there isn’t anything preventing Void OnGUI itself from running. Any ideas?

	void OnMouseDown() {
	transform.parent.GetComponent<ParentScript>().curGO = gameObject;
		void OnGUI(){
		if(gameObject == transform.parent.GetComponent<ParentScript>().curGO){
		GUI.Window(0, new Rect(Screen.width/2 + 200, Screen.height/2 - 275, 300, 550), WindowFunction, "Window Function");

if you want to compare two game objects compare it ids… by using getinstanceid()… this is the best practice as every gameobject has an unique id

I figured it out I was calling Void OnGUI from another script and it cancelled out the other(in this case my GO script).