InvokeReapting() Repeat rate not updating

When I shoot I use InvokeRepeating to continuously shoot until I let go of space. In game there is a powerup which decreases this repeat rate but I need to stop shooting then star shooting for it to actually make an effect and when the repeat rate variable in the code is set back to normal it doesn’t take effect until I stop shooting and start shooting again.

How would I fix this so that it updates without me having to stop shooting and start shooting agian?

instead of InvokeRepeating() try this

float fireRate = 1f;
bool shooting = true;

IEnumerator fire(){
		Debug.Log("fire" + fireRate);
		yield return new WaitForSeconds(fireRate);

and then use StartCoroutine(fire());

so when you start shooting call fire() and set shooting to true, then to stop shooting just set it to false.