serial.print not working

so I made this script for a motion sensor and Im using serial.print for debugging and stuff but its not working. could someone see is there is a bug in my code? its for a mega2560.

int sensorValue = 0;
int outputValue = 0;
void setup() {
// put your setup code here, to run once:
int sensorValue = 0;
int outputValue = 0;
}

void loop() {
sensorValue = analogRead(2);
// put your main code here, to run repeatedly:
Serial.print(sensorValue);
if(sensorValue > 300){analogWrite(13, sensorValue);}
}

could someone see is there is a bug in my code?

What I see is that setup() should contain

Serial.begin(baudRate);

cattledog:
What I see is that setup() should contain

Serial.begin(baudRate);

its not working still, and also the sensor doesnt turn on the light when triggered

Is the serial monitor set to the same baud rate as the sketch.

setup() also needs

pinMode(13, OUTPUT);

cattledog:
Is the serial monitor set to the same baud rate as the sketch.

setup() also needs

pinMode(13, OUTPUT);

yes, so its printing everything but only on one line one

I can't see your updated code.
I don't know what light you mean.
The biggest value for analogWrite is 255 and you are using 301 or more. I don't know what happens with analogWrite with values over 255.
I can't see your wiring or your sensor.
I don't know what Arduino you have so I don't know if you can do PWM on pin 13.
etc.

You probably intended Serial.println(...) instead of Serial.print(...).

What was done to get printing working?

I figured it out, it works, thx