3D Text Problem

So I’ve had this problem for awhile, but never have been able to figure it out. here is an example script of something that wont work on 3D text.


var Money = 0;

function Update(){

guiText.text = Text;
}

Problem that appears: Cannot convert “int” to “String”

So how can I get this to work? Any help is appreciated.(P.S, If there is a duplicate question of this, sorry, I tried looking it up but didn’t know what to look up for this problem)

This question is somewhat confusing: you mention 3D text (actually TextMesh) but your code apparently uses a GUIText, and you assign Text to guiText.text, not Money. Based on the error message, I suppose that you want to print the value of Money - am I right? If so, you must explicitly convert a numeric variable to string with ToString(), or just add some text to it. In order to access the text property of a 3D text, use GetComponent to get the TextMesh reference:

GetComponent(TextMesh).text = Money.ToString(); // use ToString()

or

GetComponent(TextMesh).text = "Money is "+Money; // add a string to the number

NOTE: GetComponent is a little different in C#:

GetComponent<TextMesh>().text = "Some text";