Display GUIText on click

Hi all, real noob here. I would like to display some text when I click on an object.
EX: I click on a sphere and “This is a sphere” I click on a cube “This is a cube”.

I thought the best way was to add a GUIText to each object and fill the label, but I’m lost after that to create the script in JS.
Could someone please point me in the right direction, or better yet provide a snippet.

Thanks

Wrote a script to help you. It displays the name of the object being clicked.

#pragma strict
var isClicked : boolean;

function Start () 
{
	isClicked = false;
	if (gameObject.GetComponent(Collider) == null)
	{
		gameObject.AddComponent(typeof(BoxCollider));
	}
}

function OnInputDown()
{
	isClicked = true;
}
	
function OnInputUp()
{
	isClicked = false;
}

function OnGUI()
{
	if (isClicked == true)
	{
		GUI.Label(new Rect(5,5,400,100), "This is " + this.name);
	}
}

Check Unity documentation:
Search for Raycast to solve the “click on a sphere” problem and GUIText or GUI.Label for the “display text” problem.