OnMouseOver function, can't get it to work!

I’m trying to show a GUI text when mouse over, and when mouse exits i want it to disappear.
I have a collider, I have the script attached where i want it, and I have a GUI prefab That is attached to the script

var textObject : GUIText;

function onMouseOver()
{
textObject.text = gameObject.name;
}

function onMouseExit ()
{
textObject.text = “”;
}

Its case sensitive. So use OnMouseOver and OnMouseExit :wink:

Oh… Thanks, but still not working!! :frowning:

It should work… You attached the script and the collider to a gameobject i think and where is you guitext? try something else, attach an tag to the object with the guiText and change your script like this:

var textObject : GUIText;

function Start()
{
textObject = GameObject.FindGameObjectWithTag("tag").guiText;
}

function OnMouseOver()
{
textObject.text = gameObject.name;
}

function OnMouseExit ()
{
textObject.text = "";
}

There’s no mistake in your script.

void OnMouseOver()
{
GameObject.Find(“GUI Text”).GetComponent().text=“OnMouseOver”;
}

void OnMouseExit()
{
GameObject.Find(“GUI Text”).GetComponent().text=“OnMouseExit”;
}

use this.create guitext and copy this script to that gm.