weird spawning issue - Unity 2D

Scripts being used

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

public class AdditionSpawner : MonoBehaviour
{
    [Header("ADDITION SPAWNER")]

    [Header("List Data")]
    public int num1;
    public int num2;
    public List<int> valuesList = new List<int>();

    [Header("Spawn")]
    public float spawnInterval;
    public float initialDelay;
    [SerializeField] private bool isSpawning = false;

    [Header("Scripts")]
    [SerializeField] private AdditionGame game;
    [SerializeField] private CountdownTimer countdownTimer;
    
    [Header("GO")]
    [SerializeField] private GameObject additionPrefab;
    [SerializeField] private GameObject spawner;
    [SerializeField] private GameObject countDownTimerGO;
    [SerializeField] private Canvas canvas;

    [Header("Extra")]
    public Transform canvasTransform;
    public bool countdownFinished = false;

    private void Start()
    {
        countdownTimer.additionSpawner = this;
        valuesList.Add(0); // initialize the list with an initial value of 0
        Invoke(nameof(FinishCountdown), countdownTimer.countdownTime);
        StartCoroutine(SpawnAdditionsCoroutine(spawnInterval, initialDelay));
    }

    private void Update()
    {
        print(isSpawning);
    }

    public void FinishCountdown()
    {
        countdownFinished = true;
        Invoke(nameof(FinishedCounting), 0.5f);
    }

    public void FinishedCounting()
    {
        countDownTimerGO.SetActive(false);
    }

    private IEnumerator SpawnAdditionsCoroutine(float interval, float delay)
    {
        yield return new WaitForSeconds(delay);

        while (countdownFinished == true)
        {
            if (isSpawning == false)
            {
                isSpawning = true; 
                print(isSpawning);
                SpawnAddition();
            }

            yield return new WaitForSeconds(interval);
        }
    }

    public void SpawnAddition()
    {
        if (isSpawning == true)
        {
            Vector3 spawnPosition = spawner.transform.position;
            Quaternion spawnRotation = Quaternion.identity;
            GameObject newAddition = Instantiate(additionPrefab, spawnPosition, spawnRotation);
            num1 = Random.Range(1, 9);
            num2 = Random.Range(1, 9);

            game.additionText.text = num1 + " + " + num2;
            newAddition.transform.SetParent(canvas.transform);
            valuesList.Add(num1 + num2);

            isSpawning = false;
        }
    }
}

using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AdditionGame : MonoBehaviour
{
    public TMP_Text additionText;
    public TMP_Text scoreText;
    public TMP_InputField inputField;
    public Button answerButton;
    public GameObject additionPrefab;
    public float speed = 2f;
    private int score = 0;

    [SerializeField] AdditionSpawner spawner;
    void Start()
    {
    }

    void Update()
    {
        GameObject[] additions = GameObject.FindGameObjectsWithTag("Addition");
        foreach (GameObject addition in additions)
        {
            addition.transform.Translate(Vector3.down * Time.deltaTime * speed);
        }
    }
    public void CheckAnswer()
    {
        int answer = int.Parse(inputField.text);
        inputField.text = "";
        int correctAnswer = spawner.num1 + spawner.num2;
        GameObject[] additions = GameObject.FindGameObjectsWithTag("Addition");
        foreach (GameObject addition in additions)
        {
            if (answer == correctAnswer)
            {
                Destroy(addition);
                score++;
                scoreText.text = "Score: " + score;
                break;
            }
        }
    }

}

using System.Collections;
using TMPro;
using UnityEngine;

public class CountdownTimer : MonoBehaviour
{
    public float countdownTime = 3f;
    public TMP_Text countdownText;
    public AdditionSpawner additionSpawner;

    private void Start()
    {
        StartCoroutine(Countdown());
    }

    private IEnumerator Countdown()
    {
        float timeRemaining = countdownTime;

        while (timeRemaining > 0f)
        {
            timeRemaining -= Time.deltaTime;
            int secondsRemaining = Mathf.CeilToInt(timeRemaining);
            countdownText.text = secondsRemaining.ToString();
            yield return null;
        }
        additionSpawner.SpawnAddition();
    }
}

Rest of the inspector img’s

Hello, my name is Bunny and i have a weird spawning issue that i cant seem to fix and it might be something simple im not seeing so pls help.

when i start the game and the timer hits 0 it spawns and addition but this addion doesnt get seen by my int num1 and int num2 that make the math addition to get solved. normaly when it does it gets added and put in a list then (still needs to be build) what needs to happen is i fill in the answer in the inputfield and press a on screen enter button that then checks if the element 0 in the list matches that filled in answer.

my literal only issue is that spawn that doesnt get seen.

i hope yall can help.

@Bunnykilll - I believe I see the issue with your spawning problem. The problem seems to be that the first addition is spawned in the CountdownTimer script when the countdown hits 0, but your AdditionSpawner script is designed to handle spawning and managing the values.

To fix this, you can modify your CountdownTimer script to call the FinishCountdown method in the AdditionSpawner script instead of spawning the addition directly. This way, the spawning logic is always handled by the AdditionSpawner script.

Something like this (Warning, untested):

using System.Collections;
using TMPro;
using UnityEngine;

public class CountdownTimer : MonoBehaviour
{
    public float countdownTime = 3f;
    public TMP_Text countdownText;
    public AdditionSpawner additionSpawner;

    private void Start()
    {
        StartCoroutine(Countdown());
    }

    private IEnumerator Countdown()
    {
        float timeRemaining = countdownTime;

        while (timeRemaining > 0f)
        {
            timeRemaining -= Time.deltaTime;
            int secondsRemaining = Mathf.CeilToInt(timeRemaining);
            countdownText.text = secondsRemaining.ToString();
            yield return null;
        }
        additionSpawner.FinishCountdown(); // Call FinishCountdown() instead of SpawnAddition()
    }
}

Let me know if this gets you closer to an answer.