Buzzer interfering with Photo Resistor and Servo Motor

Hi, I am new to using Arduino but I wrote this code in an attempt to change the angle of a Servo Motor with a Photo Resistor, while also playing a series of notes from a buzzer. I have the code for the buzzer commented out because the two sets of codes work separately, but when put together, it seems like the code for the buzzer interferes with the code for the Servo Motor. I would love some help so I can learn how to fix it!

#include <Servo.h>
Servo servo1;
int sensorPin = 0;
int sensorValue01 = 0;
/*const int buzzerPin = 8;
const int songLength = 22;
char notes[] = "abCabC aa aa abC aaabC ";
int beats[] = {1,1,1,1,1,1,4,1,1,4,1,1,4,1,1,1,4,1,1,1,1,1};
int tempo = 75;*/

void setup() 

{
  servo1.attach(9);
  /*pinMode(buzzerPin, OUTPUT);*/
}

void loop()
{

  sensorValue01 = analogRead(sensorPin); //value of the light sensor, normaly between 0 ad 1023
  int angle = sensorValue01 / 6; // to obtain angle between 0 and 170
  angle = angle + 5; // to obtain value between 5 and 175
  servo1.write(angle); //move the servo
  delay(10); // to cool the jitter?
  int i, duration;
}
  /*
  for (i = 0; i < songLength; i++) // step through the song arrays
  {
    duration = beats[i] * tempo;  // length of note/rest in ms
    
    if (notes[i] == ' ')          // is this a rest? 
    {
      delay(duration);            // then pause for a moment
    }
    else                          // otherwise, play the note
    {
      tone(buzzerPin, frequency(notes[i]), duration);
      delay(duration);            // wait for tone to finish
    }
    delay(tempo/10);              // brief pause between notes
  }
   while(true){}
}

int frequency(char note) 
{
  
  int i;
  const int numNotes = 8;  // number of notes we're storing

  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523};
  
  for (i = 0; i < numNotes; i++)  // Step through the notes
  {
    if (names[i] == note)         // Is this the one?
    {
      return(frequencies[i]);     // Yes! Return the frequency
    }
  }
  return(0);  // We looked through everything and didn't find it,
              // but we still need to return a value, so return 0.
}
*/

So, with the code for the buzzer commented out, the rest works as expected (control servo by light sensor)?
What hardware setup do you have on A0 to read the light level. You should have a capacitor about .1uf there along with the voltage divider.