How to replace this Gui text with text mesh please ?

function OnGUI(){
GUI.Box (Rect (240,10,110,100), “Laps” + lap);
}

I am having trouble changing this on gui text with a text mesh :frowning: can anyone give me an idea please ? :slight_smile:

Camera.main.GetComponentInChildren(TextMesh).text = “Lap:”+lap;

this is not working :frowning:

When you say “it’s not working”, what does that mean? Do you get compiler errors? Do you get runtime errors? If so, what error do you get.

As far as i remember GetComponentInChildren doesn’t have type-inference in UnityScript, so try the generic version:

    Camera.main.GetComponentInChildren.<TextMesh>().text = "Lap:" + lap;

ps. If you just want to get rid of the box-framw, use a Label instead or use a different style:

    GUI.Label (Rect (240,10,110,100), "Laps" + lap);
    // or
    GUI.Box (Rect (240,10,110,100), "Laps" + lap, "Label");