I have problem with joystick

int joysag;
int joysol;
int pot;
void setup() {
  // put your setup code here, to run once:
pinMode(11,OUTPUT);
pinMode(3,OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
}
void loop() {
  // put your main code here, to run repeatedly:
joysag=analogRead(A2);
 joysag=map(joysag,0,1023,0,2); 
  joysol=analogRead(A1);
  joysol=map(joysol,0,1023,0,2);
  pot=analogRead(A0);
  pot=map(pot,0,1023,0,2);

  if(pot==0){
    analogWrite(11,0);
    analogWrite(6,0);
    analogWrite(5,0);
    analogWrite(3,0);
  }
    if(pot==1&&joysag==1&&joysol==1){
    analogWrite(11,170);
    analogWrite(6,170);
    analogWrite(5,170);
    analogWrite(3,170);
    }
    if(pot==1&&joysag==1&&joysol==0){
    analogWrite(11,255);
    analogWrite(6,170);
    analogWrite(5,170);
    analogWrite(3,170);
    }
    if(pot==1&&joysag==1&&joysol==2){
    analogWrite(11,170);
    analogWrite(6,255);
    analogWrite(5,170);
    analogWrite(3,170);
    }
    if(pot==1&&joysag==0&&joysol==1){
    analogWrite(11,170);
    analogWrite(6,170);
    analogWrite(5,255);
    analogWrite(3,170);
    }
    if(pot==1&&joysag==2&&joysol==1){
    analogWrite(11,170);
    analogWrite(6,170);
    analogWrite(5,170);
    analogWrite(3,255);
    }
    if(pot==2&&joysag==1&&joysol==1){
    analogWrite(11,255);
    analogWrite(6,255);
    analogWrite(5,255);
    analogWrite(3,255);
    }
    if(pot==2&&joysag==1&&joysol==0){
    analogWrite(11,255);
    analogWrite(6,170);
    analogWrite(5,170);
    analogWrite(3,170);
    }
    if(pot==2&&joysag==1&&joysol==2){
    analogWrite(11,170);
    analogWrite(6,255);
    analogWrite(5,170);
    analogWrite(3,170);
    }
    if(pot==2&&joysag==0&&joysol==1){
    analogWrite(11,170);
    analogWrite(6,170);
    analogWrite(5,255);
    analogWrite(3,170);
    }
    if(pot==2&&joysag==2&&joysol==1){
    analogWrite(11,170);
    analogWrite(6,170);
    analogWrite(5,170);
    analogWrite(3,255);
    
    }
   
    
  
}[\code]

I wanted to control 4 leds with this code but it did nonsense things.

What is it doing that is different from what you thought you told it to do?

How did you wire the joystick and pot? Are they connected to +5V at one end an GND at the other?