I have a prefab with a script attached to it, I am trying to access a text GameObject to count up, I tried plenty of things. My code: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class TreeItem : MonoBehaviour { public GameObject obj; public float itema = 0; void Start() { player = GameObject.FindGameObjectWithTag("tree").GetComponent<Transform>(); } public void Wreck() { Debug.Log("clicked"); itema = itema + 1; Destroy(this.gameObject); } void Update() { Tree.text = itema.ToString(); } }
also, one thing the text I want to count up is not a prefab but the object that the script is attached to is a prefab