problem changing spawnTime variable

I’m having trouble getting my objects to react accordingly. For testing, I have my timer set to spawn every second, then, when my score reaches 5 or above, I would like to change the timer to every 5 seconds.

As it is, the enemies still come every second. I have a Debug.Log() in there and it displays the spawnTime variable as 5, but the enemies still come every second.

I have a feeling it’s because it is in my Start() function but in the update function, hundreds of enemies spawn. How can I get around this? Thanks

using UnityEngine;
using System.Collections;

public class spawn : MonoBehaviour
{
	// Prefab to spawn
    public GameObject spawnableObject;

	public GameObject[] prefab;
	private int timeToBegin = 2;
	private float spawnTime = 1;
	
	Vector3[] spawnPoints;

	int endOfArray;

	void Start()
	{
		//The point in which the new prefab will be spawned
		GameObject[] objs = GameObject.FindGameObjectsWithTag("SpawnPoints") as GameObject[] ;
		spawnPoints = new Vector3[objs.Length] ;
		
		for(int i = 0 ; i < objs.Length ; i++)
		{
			spawnPoints _= objs*.transform.position ;*_

* }*
* endOfArray = spawnPoints.Length;*
* InvokeRepeating (“Spawn”, timeToBegin, spawnTime);*
* }*

* void Update()*
* {*
* if(accelShotHS.score >= 5)*
* {*
* spawnTime = 5.0f;*
* Debug.Log(spawnTime);*
* }*
* }*
}

Right after you set your spawnTime to 5 you also need to cancel the old InvokeRepeating() call using CancelInvoke(), then call InvokeRepeating() again with the new spawnTime.