Grabbing UI text as a public variable?

Hello, I am watching a tutorial for making a game in Unity and I’m having an issue with one of my scripts. The tutorial I’m watching uses the old GUI system instead of the new UI system, so I’m having a hard time replicating what the tutorial is looking for in the UI system. Here’s the code that the tutorial uses, w/ the GUI system:

using System.Collections;
using UnityEngine;

public class Finish : MonoBehaviour {

	public GUIText winText;

	// Use this for initialization
	void Awake () 
	{
		winText.enabled = false;
	}

	void OnTriggerEnter (Collider other)
	{
		if (other.gameObject.tag == "Player") 
		{
			winText.enabled = true;
		}
	}
}

How do I replicate the “public GUIText winText” with the UI system? Also, do I need to put “using UnityEngine.UI” at the top of this script? Thank you in advance!

IIRC, to convert the two all you would need is to replace GUIText with Text, and yes add UnityEngine.UI to the top of the script. Also, if you want to change to text via script, you need to assign it through Text.text

In the new Ui system just add the UnityEngine.Ui, and use the class called “Text”:

  using System.Collections;
  using UnityEngine;
  using UnityEngine.Ui;

 public class Finish : MonoBehaviour 
 {
   //Text Class.
   public Text winText;

   // Use this for initialization
   void Awake () 
   {
       winText.enabled = false;
   }

    void OnTriggerEnter (Collider other)
    {
        if (other.gameObject.tag == "Player") 
        {
            winText.enabled = true;
        }
    }
}