Object does not instantiate, causing an error while attempting to get a component.

I am presently working on translating a VR dodgeball game to the Oculus Quest 2, which sees the player use a ball to deflect oncoming balls. In this game, as the “Start Game” button is pressed, a coroutine should start, spawning the dodgeballs in the throwers’ hands. In the Vive/SteamVR version of the application, the menu cannot be accessed by the player in the headset, instead an administrator manages the menu from the computer. The coroutine is shown below:

public void spawnBall() {
            ball = Instantiate(ballPrefab, ballSpawnLocation.position, Quaternion.identity);
            ball.transform.localScale = new Vector3(EnemyController.ballSize, EnemyController.ballSize, EnemyController.ballSize);
            ball.transform.parent = ballSpawnLocation;
            ball.transform.rotation = Quaternion.LookRotation(-Vector3.forward);

            if (listener) {
                listener = false;

I have recreated the menu so that the player inside the headset can access it and start the game. However, when the start button is pressed by the player, the coroutine does not run, and no balls spawn inside the throwers’ hands. This results in a null reference exception, as the script controlling the throwers attempts to reference the Rigidbody component attached to the ball prefab.

Rigidbody ballRigid = ball.GetComponent<Rigidbody>();

The ball never spawns, which also causes the throwers’ animation to activate, however it does not reset into the idle animation. I am currently attempting to have the coroutine run again as the Start Game button is pressed, however I am unsure how to approach it.

Relevant photos are attached to this link: https://drive.google.com/drive/folders/13hM3iZpskkl-dk72PT0IPac29lnswRCB?usp=sharing

I had an issue quite similar, the problem was my declaration of the object to be referenced. My exact issue was:

        body = transform.Find("Body").gameObject;

        shoulderL = transform.Find("Shoulder L").gameObject;

        shoulderR = transform.Find("Shoulder R").gameObject;

        armL = transform.Find("Shoulder L/Arm L").gameObject;

        armR = transform.Find("Shoulder R/Arm R").gameObject;

I didn’t know that a “/” needed to be placed for children within children, as armL was just Find("Arm L") before.
My null reference was only on Arm L(and a GetComponent of it), and nothing worked after it. No other errors, even though the other arm would have had the same issue. What is your error exactly, and where?

I figured out that this was the result of me having more than one UI object with the startGame function. It seems like the game becomes confused when more than one button starts the game, and does not instantiate the balls as expected.