If it sounds good, it is good
Yep.
If it helps:
In western music, there are 12 notes total (A - A# - B - C - C# - D - D# - E - F - F# - G - G#). A sharp note (#) is the same as the note above flatted (b); thus, G# is also called Ab. For mysterious reasons there is no B#/Cb or E#/Fb. It then repeats from A again, but higher - called an
octave.
A
key is a set of seven notes. Going from one note to the next (like A to A#) is a half-step, and the different keys have different patterns for how they select their seven notes. Skipping a note is two half-steps, in other words a whole step.
So, a
major key will start from any note you like - let's say A - and it will then go WWHWWWH (W - whole step, H - half step). So the key of A major will go A - B - C# - D - E - F# - G# - A (starting over again an octave higher). That's also the A major scale.
A
minor key will go WHWWWHW from the starting note. So A minor goes A - B - C - D - E - F - G - A. That's also the A minor scale.
So to go back to your original question; yes, normally, you and your guitarist should be playing in the same KEY. That means that whatever notes each of you are playing, they should be selected from the same set of seven notes. But you don't have to play in unison, which would be playing the same note at the same time.
For instance, if your song is in the key of A minor, neither of you should be playing any sharp or flat notes. But you might be playing an A while he's playing a C or a D. Those notes are both in the key, and should harmonize nicely.
Having said that, as Charlie Monroe said - if it sounds good it is good. Rules are made to be broken, and lots of music does break the rules. Classical composers often put in "accidentals," notes outside the key that create a little tension by clashing with what you expect to hear. Blues adds the "blue note" between the fourth and fifth notes of the key. But you should learn the rules before you set out to break them, so that you understand what you're doing and why.