Project 4 help, seems to be crashing when sensors input change

Hey so like many i have started making my way through the starter kit. My project 4 seems to be unresponsive compared to videos ive seen of a working project 4.

When i apply power, and the board powers on, the led will sit off until i make any type of change to the photo-resistors (could be me just waving my hand near), then the led might turn blue for a second or two, then turn red maybe for a second or two, then it might change two a sort of white. Sometimes the LED might change color in a different order before it locks on to a finishing color, where is assume is freezes.

I mainly assume its crashing because when i use the serial monitor the device seems to record the sensor outputs correctly(there are 3, one for each color in rgb LED) until a change is made to the sensors and the serial monitor will freeze.

The LED seems to not be getting the appropriate Voltage for what the sensor is reading. (this was done with a voltage check, not sure if thats accurate because its faded with PWN)

I am very new to programming so my first thought is to just have someone look at it to see if i made an obvious mistake, and if not, i could provide further details.

Disregard the notes on two lines, i had to make adjustments to make sure it looked good.

const int greenLEDPin=9;
const int blueLEDPin=10;              // makes each pin its own constant, they will be made outputs in 
const int redLEDPin=11;                   setup

const int greenSensorPin=A0;
const int blueSensorPin=A1;          //makes each anolog input its own constant variable, they are automatically inputs
const int redSensorPin=A2;

int G =0;
int B=0;                    // variable to record value of each LED
int R=0;

int greenPinValue=0;
int bluePinValue=0;                //variable to record anolog value at each phototransistor
int redPinValue=0;


void setup(){
  Serial.begin (9600);
  pinMode (greenLEDPin,OUTPUT);        // setup communication for serial monitor, define pins asoutputs
  pinMode (blueLEDPin,OUTPUT);
  pinMode (redLEDPin,OUTPUT);}
  
 void loop(){
   greenPinValue= analogRead (greenSensorPin);
   delay (5);
   bluePinValue= analogRead  (blueSensorPin);  //reads each value of analog input pins and stores it in 
   delay (5);                                                     coordinationg color variable
   redPinValue= analogRead  (redSensorPin);
   
   Serial.print("Sensor Values \t Green");
   Serial.print(greenPinValue);
   Serial.print("\t Blue");
   Serial.print(bluePinValue);
   Serial.print("\t Red");
   Serial.println(redPinValue);
   
   G= greenPinValue/4;
   B= bluePinValue/4;              //output of analog inputs= 0-1023 PWN need a value 0-255,1023/4 =255
   R= redPinValue/4;
   
   
   Serial.print("LED VALUES \t Green: ");
   Serial.print(G);
   Serial.print("\t Blue: ");
   Serial.print(B);
   Serial.print("\t Red: ");
   Serial.println(R);
   
   analogWrite(greenPinValue, G);
   analogWrite(bluePinValue, B);
   analogWrite(redPinValue, R);
   
 }
 analogWrite(greenPinValue, G);
   analogWrite(bluePinValue, B);
   analogWrite(redPinValue, R);

Look carefully.

Try to involve these values in your solution

const int greenLEDPin=9;
const int blueLEDPin=10;              // makes each pin its own constant, they will be made outputs in
const int redLEDPin=11;

Thanks AWOL, this is my first time on the forum, but i know understand what a tool this can be.