Why can't I use if else to change the color of the RGB led?

Likely with PWM but…
Which RGB Led?
Which Potentiometer?
Give us details

(read How to get the best out of this forum and provide the necessary documentation for your ask).