Having a problem with Text

I was trying to implement a score so I created a text and assigned the value for the score.
The Text is doing its job and it updates when the score increases.
The problem is that those errors appear even tho everything is working.

using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
using UnityEngine.UI;

public class UserScore : MonoBehaviour
    public Text scoreText;
    public int gameScore = 0;
    public int topScore = 0;

    PlayerController playerControllerScript;
    // Start is called before the first frame update
    void Start()
        scoreText = GameObject.Find("ScoreText").GetComponent<Text>();
        playerControllerScript = GameObject.Find("Player").GetComponent<PlayerController>();
        topScore = PlayerPrefs.GetInt("Highscore");

    // Update is called once per frame
    void Update()
        scoreText.text = $"{gameScore}";
        if (gameScore > topScore)
            topScore = gameScore;
            PlayerPrefs.SetInt("Highscore", topScore);
        if (playerControllerScript.gameOver == true)
            gameScore = 0;

Let me know what you think.

Line 16 appears to be

scoreText = GameObject.Find("ScoreText").GetComponent<Text>();

Only one thing on that line would cause an NRE.

So you should logically conclude that there is no “ScoreText” object in your scene.

You also should either make your scoreText variable public/[SerializeField], or assign it in Awake/Start. Not both. You’re overriding any work you may have done assigning it in the inspector.