Help with programming

 int sensorPin0= A0;
int speakerPin = 3;
int sensorValue0 = 0;

void loop () {
sensorValue0 = analogRead (sensorPin0);
do
{
 tone (3, 261)

} While (sensorValue0 <300);
}

There is no error, but the buzzer doesn't play note when sensor is less than 300

Right.

There is no setup() function so there is no way that your code will compile with the Arduino IDE and you are missing a semicolon after the tone statement and the while is capitalized. Without setup() there is no pinMode(speakerPin, OUTPUT) so the buzzer wouldn't work, anyway.

Try this. It may not do what you want but it does compile.

int sensorPin0= A0;
int speakerPin = 3;
int sensorValue0 = 0;

void setup()
{
  pinMode(speakerPin, OUTPUT);
}

void loop ()
{
  sensorValue0 = analogRead (sensorPin0);
  do
  {
    tone (3, 261);
  }
  while (sensorValue0 <300);
}

What about

void loop () {
if (analogRead (sensorPin0)<300)
  tone (3, 261);
  else noTone();

}

Since this won't compile, show us your real code.

You do know that you should always get a tone, since the do is always executed at least once.