How can i make my GUI Button appear above my clicked object?

Alright here’s what i’m doing.

I’m trying to make a 3D Card game.

So when ever I click a card that is in my hand, I want a GUI.Button to appear over my card Object because i clicked it. And the button appear as Summon so when i click summon it’ll apply it’s effect. Pretty simple right? Can any1 help please?

BTw. Here’s my existing code. for FUnction GUI.

function OnGUI()
{        var x = Event.current.mousePosition.x;
        var y = Event.current.mousePosition.y;
    if (clicked == true)
    {
       
	  if (GUI.Button (Rect (x,y, 100, 20), "Summon")) {
		
		ApplyEffect = true;
		clicked = false;
		

	}
	else {
	}
       }
}

Getting something like this working is often fussy. It is not just about placing the button to go away if the user clicks outside the cards, and you want the button to move if the user clicks on another card, and the button has to go away if the user uses the button. Here is a bit of code to get you started. It should be placed on a single object in the scene. It assumes that your cards are tagged ‘Card’. I assume that you will want different behaviors based on what card is used in the summoning. If so, you can get the information from the ‘hit’. You can use either the name of the object (hit.collider.name), or you can use hit.collider.GetComponent() to get the script with specific info or to execute methods on that card.

#pragma strict

private var showButton = false;
private var pos : Vector2;
private var hit : RaycastHit;

function OnGUI() {
	var e = Event.current;

    var x = pos.x - 50;  // Calc x and y to center of button
    var y = pos.y - 10;

    if (showButton && GUI.Button (Rect (x,y, 100, 20), "Summon")) {
    	Debug.Log("Summoning");
    	showButton = false;
    } else {
		if (e.type == EventType.MouseDown) {
			CheckClick();
		}
	}
}

function CheckClick() {
	var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	
	if (Physics.Raycast(ray, hit)) {
		if (hit.collider.tag == "Card") {
			pos = Camera.main.WorldToScreenPoint(hit.transform.position);
			pos.y = Screen.height - pos.y;  // convert from Screen to GUI
			showButton = true;
		}
	}
	else {
		showButton = false;
	}
}