Error BCE0049

Here’s the script :

#pragma strict

var health : float = 100;
var healthString : String;
var healthText : UI.Text;

function Start () {

healthText = gameObject.GetComponent(UI.Text);
	
}
function Update () {

health = 90;
gameObject.GetComponent(UI.Text) = health;

}

What it’s meant to do is change the text to 90.

I get the error Assets/HealthScript.js(15,24): BCE0049: Expression ‘self.gameObject.GetComponent(UI.Text) cast UnityEngine.UI.Text’ cannot be assigned to.

How do I fix this?

Thanks in advance

Hey @Chickenator

Did you see the update I put on?

 #pragma strict
 
 import UnityEngine.UI;
 
 var health : float = 100;
 var healthString : String;
 var healthText : UI.Text;
 var healthTxtGO : GameObject;
 
 function Start () {
     healthText = healthTxtGO.GetComponent(UI.Text);
 }
 function Update () {
     health = 90;
     healthText.text = health.ToString();   
 }