can anybody help me with this script?

I was following a tutorial on how to make collectibles with a UI counter I was trying everything I could and I just took it back to the tutorial skeleton and here it is please help

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class gameManager : MonoBehaviour
{
public int currentGold;
public Text goldText;
// Start is called before the first frame update
void Start()
{

}
// Update is called once per frame
void Update()
{

}
public void AddGold(int goldToAdd)
{
currentGold += goldToAdd;
goldText.text = "Gold: " + currentGold;

Here is the other part (I commented it so I could still work on the project)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class goldPickup : MonoBehaviour
{
/* public int value;
// Start is called before the first frame update
void Start()
{

}
// Update is called once per frame
void Update()
{

}
private void OnTriggerEnter(Collider other)
{
if(other.tag == “Player”)
{
FindObjectOfType().AddGold(value);

Destroy(gameObject);
}
}
*/
}

How do you expect anyone to help you with your problem if you don’t actually describe your problem?

1 Like

I debugged and I think my project isnt recognizing the UnityEngineUI an error pops up because of Text.text

If you’re asking for help with the error, you should probably post the error.