Cannot convert int to string

I’m trying to fetch my characters health from a seperate script and use it to change a GUI text but I’m getting the Cannot convert int to string error.

//This is my script to set the GuiText
var hp = attributes.health;
guiText.text = hp;

//This is my attributes script to store health
static var health = 10;

Easy cheat is to set your string as an empty string plus the int

int hp = 10;
string text = ""+hp;          // sets text to "10"

You can directly do this with GUIText.text = “”+hp

int hp = 10;
string hpText = hp.ToString();

ToString is a method that every object in C# has. It’s part of System.Object itself.

No, it’s every object in .NET (or rather Mono in this case), not related to C# (plus the question is using Unityscript, which also uses Mono).

–Eric

I’m maybe missing something, but what makes you think it’s in UnityScript?

EDIT: Ah! Yeah… you can’t “static var” in C#.