text.text? help ui

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class energiaText : MonoBehaviour
{

Text text;
vida vidaText;


void Start()
{
    
    vidaText = GetComponent<vida>();
    
}

// Use this for initialization
void Awake()
{
    text = GetComponent<Text>();

}
// Update is called once per frame
void Update()
{
    text.text = "Energia: "+ vidatText.life1;

}

//===========================
//other class :slight_smile:

using UnityEngine;
using System.Collections;

public class vida : MonoBehaviour {

public float life;

void Update () {
life = life + 1;
}
}

//------------------------------------

NullReferenceException: Object reference not set to an instance of an object
energiaText.Awake ()

//------------------------------------

the variable life does not pass to class โ€œenergyโ€ to be displayed in text Ui
The text does not mark anything :frowning: help me please

Do you have all the tags and everythimg set up, because that helps. You could use

(other.gameObject.CompareTag ("Pick Up"))

with an if statement