NullReferenceException: Object reference not set to an instance of an object CoinManager.Update () (

What is wrong with this Code? How can I use TMP_Text i do not understand this?

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

public class CoinManager : MonoBehaviour
{
    public int geld;
    public Text money;
    // Start is called before the first frame update
    void Start()
    {

    }
    // Update is called once per frame
    void Update()
    {
        money.text = geld.ToString();
    }
    public void AddMoney()
    { 
        geld++;
    }
}

This is nothing to do with 2D. Please use the Scripting, Getting Started or the TextMeshPro forums for this kind of stuff. I’ll remove the 2D tag and move to the Scripting forum for you.

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Thanks.

As Melv already posted above:

The answer is always the same… ALWAYS!

How to fix a NullReferenceException error

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Three steps to success:

  • Identify what is null ← any other action taken before this step is WASTED TIME
  • Identify why it is null
  • Fix that