after watching this https://www.youtube.com/watch?v=uE2RJAyVaHE&list=PLDj6B2jXbus1v9zD_IdPnGcim3uwSDELI&index=4 and I did what is said, I got this error NullReferenceException: Object reference not set to an instance of an object
this is the scoreboard code
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Count_Score : MonoBehaviour
{
public Text ScoreBoard;
public GameObject ball;
private int Bat_1_Score = 0;
private int Bat_2_Score = 0;
// Start is called before the first frame update
void Start()
{
ball = GameObject.Find("Ball");
}
// Update is called once per frame
void Update()
{
if (ball.transform.position.x >= 35f)
{
Bat_1_Score++;
}
if (ball.transform.position.x <= -35f)
{
Bat_2_Score++;
}
ScoreBoard.text = Bat_1_Score.ToString() + " - " + Bat_2_Score.ToString();
print(Bat_1_Score + " , " + Bat_2_Score);
}
can you tell me what I did wrong?