Headbob change when sprinting HELP

(javascript) I am trying to have my headbob values increase when left shift (sprint) is pressed, so it makes u feel like you are sprinting. Here is what i have:

private var timer = 0.0; 
 var bobbingSpeed = 0.18; 
 var bobbingAmount = 0.2; 
 var midpoint = 2.0; 
 
 function Update () { 
    waveslice = 0.0; 
    horizontal = Input.GetAxis("Horizontal"); 
    vertical = Input.GetAxis("Vertical"); 
    if (Mathf.Abs(horizontal) == 0 && Mathf.Abs(vertical) == 0) { 
       timer = 0.0; 
    } 
    else { 
       waveslice = Mathf.Sin(timer); 
       timer = timer + bobbingSpeed; 
       if (timer > Mathf.PI * 2) { 
          timer = timer - (Mathf.PI * 2); 
       } 
    } 
    if (waveslice != 0) { 
       translateChange = waveslice * bobbingAmount; 
       totalAxes = Mathf.Abs(horizontal) + Mathf.Abs(vertical); 
       totalAxes = Mathf.Clamp (totalAxes, 0.0, 1.0); 
       translateChange = totalAxes * translateChange; 
       transform.localPosition.y = midpoint + translateChange; 
    } 
    else { 
       transform.localPosition.y = midpoint; 
    
	if(Input.GetKey("left shift")){
			var bobbingSpeed = 0.25; 
			var bobbingAmount = 0.7; 
			var midpoint = 4.0; 
		
	
	} 
 
 }

The problem is you are trying to declare variables that are already declared. Everything in the if(Input.GetKey(“left shift”)) should not have the keyword var.

But then you will run into the problem where you have permenantly changed the values, so what happens when the Shift is not pressed?

var bobbingSpeed = 0.18;
var bobbingAmount = 0.2;
var midpoint = 2.0; 

var bobbingWalkSpeed = 0.18;
var bobbingWalkAmount = 0.2;
var midpointWalk = 2.0; 

var bobbingRunSpeed = 0.25;
var bobbingRunAmount = 0.7;
var midpointRun = 4.0;


// In Function :

if(Input.GetKey("left shift"))
{
	bobbingSpeed = bobbingRunSpeed;
	bobbingAmount = bobbingRunAmount;
	midpoint = midpointRun;
} 
else
{
	bobbingSpeed = bobbingWalkSpeed;
	bobbingAmount = bobbingWalkAmount;
	midpoint = midpointWalk;
}