When ball activated, 2 balls appear instead of 1

Hi,
I’m totally new to this website and I hope this is the right place to post my difficulties. I’m following a unity tutorial where I’m writing a football game. The problem is the instructor is not always responsive and sometimes, some of the questions the students place are just not answered to. My question is in the description given. When I disable the characteristics below the ball and leave the correct one active, 2 balls persistently appear instead of one. I cannot continue with the course as the continuation is only possible if 1 ball appears without rolling. How can i fix this? I cannot insert the picture as there is a parsing problem. My file is .jpg.

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

public class GameController : MonoBehaviour
{
    [SerializeField]
    GameObject ballPrefab;

    /*
    [SerializeField]
    Rigidbody rb; */

    [SerializeField]
    float ballForce;

    GameObject ballInstance;
    Vector3 mouseStart;
    Vector3 mouseEnd;
    float minDragDistance = 15f;
    float zDepth = 25f;


    // Start is called before the first frame update

    private void Awake()
    {
        
    }

    void Start()
    {
        CreateBall ();

    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetMouseButtonDown(0))
        {
            mouseStart = Input.mousePosition;

        }

        if (Input.GetMouseButtonUp(0))
        {
            mouseEnd = Input.mousePosition;

            if(Vector3.Distance(mouseEnd,mouseStart) > minDragDistance)

                {
                //throw ball

                Vector3 hitPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, zDepth);

                hitPos = Camera.main.ScreenToWorldPoint(hitPos);

                ballInstance.transform.LookAt(hitPos);

                ballInstance.GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * ballForce, ForceMode.Impulse);

                }
        }
    }

    void CreateBall()
    {
        ballInstance = Instantiate(ballPrefab, ballPrefab.transform.position, Quaternion.identity) as GameObject;

    }

}

Hello.

If 2 balls are instantiated is because you are doing it twiice, somewhere, somehow, itds been called twice, or there are 2 objects with the same scrip, or something like that.

You MUST debug the code while running, and cheking when the function to create balls is called.

Bye

I cannot paste anything here but I think I can share the link. https://drive.google.com/file/d/1-Gx1mcoJwsBCxMMdYV7wEBMNEf4X4L9z/view?usp=sharing. I cannot find where the fault is. I have reviewed throught the tutorial and there’s only ONE script. You can download and check.

My best advice is to never instantiate objects, just set them active and inactive.

 void CreateBall()
     {
        ballPrefab.gameObject.SetActive(true)
         ballPrefab.transform.position = whereverYouAreTryingToInstantiateTheBall
     }

I don’t see anywhere you need to destroy the ball, so that might be why you are seeing two. Whenever you need to destroy the ball (which is typically done when you instantiate something) just type in this line of code wherever the destroying needs to happen:

ballPrefab.gameObject.SetActive(false)