RGB led only works when the green light is on

1.) You ALWAYS need resistors. No resistors = killing the LED and the arduino board
2.) You ALWAYS need 3 resistors for an RGB led, one for each color.

Using just a single 'shared' resistor doesn't work.