To find Gubby you must have the flute to do this. Go to the level where Gubby is in and go into one of the secret places with the sparkle in the air and use the flute. A switch will appear press that switch and Gubby will be free.
Just keep pressing the square button. You will be invisible.