by clicking on game object GUI text appears

i want a guitext to appear when i click on the sphere i tried this:

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);
    }
}

but this is not working

You apparently borrowed this script from this question:

http://answers.unity3d.com/questions/325148/display-guitext-on-click.html

When you do that, please make reference to the original question/author. It is both the right thing to do and gives context to answer a question.

As for why your script is not working, OnInputDown() should be OnMouseDown() and OnInputUp() should be OnMouseUp().

Not even going to lie, it looks like you tried putting Javascript into C# files, or the other way around (somehow, just what the errors look like.) Anyway, here’s what you should be doing, in C#

using UnityEngine;
using System.Collections;

public class OnClick : MonoBehavior
{
	public bool isClicked = false;
	public string name = "Some name";
	
	public void Start()
	{
		if(gameObject.GetComponent(Collider) == null)
			gameObject.AddComponent(typeof(BoxCollider));
	}
	
	public void OnMouseDown()
	{
		isClicked = true;
	}
	
	public void OnMouseUp()
	{
		isClicked = false;
	}
	
	public void OnGUI()
	{
		if(isClicked)
			GUI.Label(new Rect(5,5,400,100), "This is " + this.name);
	}
}

@tw1st3d
What have I to wrote instead of “Some name” and "This is "?