UI text showing money

I want to make a text on my screen that is showing money. Example: Money: 217 . How do i do that? i tried using this code:

GetComponent<GUIText> ().text = "Money:" + database.money;

but its GUIText but my UI text does not have that component if i do add it nothing changes only text (script) text is showing up. Can someone tell me how to do this? i tried searching everywhere but all is outdated. I am using unity 5 beta purchased.

You don’t use GUIText if you’re on 4.6 or higher.

Use UnityEngine.UI.Text like this:

using UnityEngine.UI;

// ...

Text t = GetComponent<Text>();
t.text = "Money: " + database.money;
  1. You should be using UnityEngine.UI.Text it’s apart of unity 5.

     using UnityEngine.UI;
  2. Find Your UI Text.

    GameObject textGameObj= GameObject.Find("myText");
  3. Set the text

    textGameObj.GetComponent<Text>().text = "Money:" + database.money;