I’m very new to unity and don’t understand why I get this error, in the unity editor I have an gameobject which contains this script as a component, I attached the UI-text to the script in the component but it just shows the error and the text doesn’t change.
using UnityEngine.UI;
public class GlobalScore : MonoBehaviour
{
public GameObject ScoreDisplay;
private void Update()
{
ScoreDisplay.GetComponent<Text>().text = "SCORE: ";
}
}
Its probably an easy fix but any help is appreciated