Color Fading LED

int redPin = 3;
int greenPin = 9;
int bluePin = 10;

int redVal;
int greenVal;
int blueVal;

void setup() {
  
 pinMode(redPin, OUTPUT);
 pinMode(greenPin, OUTPUT);
 pinMode(bluePin, OUTPUT);
 analogWrite(redPin, 255);
 
}

void loop() {
  
 int redVal = 255;
 int greenVal = 0;
 int blueVal = 0;
  
 for(int i = 0; i < 255; i += 1){
  greenVal += 1;
  redVal -= 1;
  analogWrite(redPin, redVal);
  analogWrite(greenPin, greenVal);
  
  delay(50);
 }   
 
 redVal = 0;
 blueVal = 0;
 greenVal = 255;
 for(int i = 0; i < 255; i += 1){ 
   blueVal += 1;
   greenVal -= 1;
   analogWrite(greenPin, greenVal);
   analogWrite(blueVal, blueVal);
   
   delay(50);
 }
 
 redVal = 0;
 blueVal = 255;
 greenVal = 0;
 for(int i = 0; i < 255; i += 1){
  redVal += 1;
  blueVal -= 1;
  analogWrite(redPin, redVal);
  analogWrite(blueVal, blueVal);
 
 delay(50); 
 }
 
}

I want an RBG LED to start at true red (255, 0, 0) and slowly ween into green, then into blue from there. I want to go about this using analogWrite, and possibly for loops. This code above quickly starts at red, then switches to a greenish yellow. I've been searching the internet for a while now, and I still can't get it to work. Any suggestions or tips?

You've got the right idea, keep working it until you get the combo's you want.
I've seen 'color wheel's that might help with color selection.

Perhaps this one

Some advice - when something does not work test the program in parts. Your fade from red to green worked, so you could have eliminated it and tested the other parts.

If something is not working use serial print to show debug messages, doing that would have showed you that the value of 'i' did not get to 255 in the green to blue section.

If you have identical blocks of code in loop() break it out into a separate function. For example, you could have written a function like this:

void fadeLed(int upPin, int downPin)
{
  int upVal = 0;
  int downVal = 255;

  digitalWrite(downPin, 255);
  digitalWrite(upPin, 0);

  for (int i = 0; i < 255; i += 1) {
    upVal += 1;
    downVal -= 1;
    analogWrite(upPin, upVal);
    analogWrite(downPin, downVal);

    delay(50);
  }

}

and called it like this:

  fadeLed(greenPin, redPin);
  fadeLed(bluePin, greenPin);
  fadeLed(redPin, bluePin);

The error in your code is that you (twice) do

   analogWrite(blueVal, blueVal);

instead of

   analogWrite(bluePin, blueVal);

If you want smoother shifting you might want to fade green up to full and THEN fade red down. That will give a full-brightness yellow between read and green.

void loop() {
  // Start at red
  analogWrite(redPin, 255);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, 0);

  // Fade to yellow
 for(int i = 0; i < 256; i++){
  analogWrite(greenPin, i); 
  delay(50);
 } 

  // Fade to green
 for(int i = 255; i >= 0; i--){
  analogWrite(redPin, i); 
  delay(50);
 }   

 // Fade to cyan
 for(int i = 0; i < 256; i++){
  analogWrite(bluePin, i); 
  delay(50);
 } 

  // Fade to blue
 for(int i = 255; i >= 0; i--){
  analogWrite(greenPin, i); 
  delay(50);
 } 

 // Fade to magenta
 for(int i = 0; i < 256; i++){
  analogWrite(redPin, i); 
  delay(50);
 } 

  // Fade to red
 for(int i = 255; i >= 0; i--){
  analogWrite(bluePin, i); 
  delay(50);
 } 
}