using UnityEngine; using UnityEngine.UI; using System.Collections; [RequireComponent(typeof(Text))] public class CoinText : MonoBehaviour { public GameObject helicopter; private Text text; private int coins; // Use this for initialization void Start () { text = GetComponent(); } // Update is called once per frame void Update () { if (helicopter != null) { coins = helicopter.GetComponent().coinTotal; } text.text = "Coins: " + coins; } }