Difficulty parameter not correctly affecting spawn rate on button click

I’ve been stuck on this problem for about a week and am at a loss of how to resolve it. I am trying to speed up the instantiate rate of the enemies when the difficulty buttons on the start screen are clicked. In order to do this I’ve set a public difficulty variable in my DifficultyButton script and set it in the inspector to 1-3 depending on the button, and I’m trying to divide the spawnIntervalEnemy float from my SpawnManager script by that variable inside my GameManager script in order to make them spawn at different rates when the corresponding button is clicked. There seems to be no errors, but all 3 buttons keep the enemies at the same spawn rate no matter which one I click. I’m having to pull variables from multiple different scripts so idk if that’s what’s causing the issue or what, and I’ve tried multiple different solutions but nothing seems to do the trick and make the buttons spawn enemies at the correct rate, so any help is appreciated. Here are my 3 scripts with the relevant code, hopefully this helps.

public class DifficultyButton : MonoBehaviour
{
    private Button button;
    private GameManager gameManager;

    public int difficulty;

    // Start is called before the first frame updateX
    void Start()
    {
        button = GetComponent<Button>();
        gameManager = GameObject.Find("Game Manager").GetComponent<GameManager>();

        button.onClick.AddListener(SetDifficulty);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void SetDifficulty()
    {
        Debug.Log(gameObject.name + " was clicked");
        gameManager.StartGame(difficulty);
    }

public class GameManager : MonoBehaviour
{
    public TextMeshProUGUI scoreText;
    public TextMeshProUGUI gameOverText;
    public static bool isGameActive;
    public Button restartButton;
    public SpawnManager other;
    public GameObject titleScreen;

    private int score;

    // Start is called before the first frame updateX
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        
    }

    // Updates Score
    public void UpdateScore(int scoreToAdd)
    {
        score += scoreToAdd;
        scoreText.text = "Score: " + score;
    }

    public void GameOver()
    {
        gameOverText.gameObject.SetActive(true);
        restartButton.gameObject.SetActive(true);
        isGameActive = false;
    }

    public void RestartGame()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }

    public void StartGame(int difficulty)
    {
        isGameActive = true;
        // Starts score at 0
        score = 0;
        UpdateScore(0);
        other.InvokeObjects();
        other.spawnIntervalEnemy /= difficulty;

        titleScreen.gameObject.SetActive(false);
    }

public class SpawnManager : MonoBehaviour
{
    public GameObject[] enemies;
    public GameObject[] obstacles;
    public GameObject[] powerup;

    private float spawnPosZ = 15;
    private float spawnRangeX = 10;
    private float startDelay = 2;
    public float spawnIntervalEnemy = 1.5f;
    private float spawnIntervalObstacle = 1.0f;
    private float spawnIntervalPowerup = 5.0f;

    // Start is called before the first frame updateX
    void Start()
    {
        InvokeObjects();
    }

    // Update is called once per frame
    void Update()
    {
        if (!GameManager.isGameActive)
        {
            CancelInvoke("SpawnRandomEnemy");
            CancelInvoke("SpawnRandomObstacle");
            CancelInvoke("SpawnPowerup");
            enabled = false;
        }
    }

    void SpawnRandomEnemy()
    {
        int enemyIndex = Random.Range(0, enemies.Length);
        Vector3 spawnPos = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), 0.75f, spawnPosZ);

        Instantiate(enemies[enemyIndex], spawnPos, enemies[enemyIndex].transform.rotation);
    }

    void SpawnRandomObstacle()
    {
        int obstacleIndex = Random.Range(0, obstacles.Length);
        Vector3 spawnPos = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), .5f, spawnPosZ);

        Instantiate(obstacles[obstacleIndex], spawnPos, obstacles[obstacleIndex].transform.rotation);
    }

    void SpawnPowerup()
    {
        int powerupIndex = Random.Range(0, powerup.Length);
        Vector3 spawnPos = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), .75f, spawnPosZ);

        Instantiate(powerup[powerupIndex], spawnPos, powerup[powerupIndex].transform.rotation);
    }

    public void InvokeObjects()
    {
        InvokeRepeating("SpawnRandomEnemy", startDelay, spawnIntervalEnemy);
        InvokeRepeating("SpawnRandomObstacle", startDelay, spawnIntervalObstacle);
        InvokeRepeating("SpawnPowerup", startDelay, spawnIntervalPowerup);
    }
}

Have you tried making “spawnIntervalEnemy” private, and changing it’s value with a public void method?
You could add a Debug.Log to check that you ACTUALLY call this method, then print the difficulty variable and the spawnIntervalEnemy after the division is made. Something like:

public class SpawnManager : MonoBehaviour
 {
 private float spawnIntervalEnemy;

private void Start()
{
spawnIntervalEnemy = 1.5f;
}

public void SetDifficulty(float difficulty)
{
spawnIntervalEnemy=spawnIntervalEnemy/difficulty;
Debug.Log("difficulty: "+ difficulty +" new value: "+spawnIntervalEnemy);
}

}