Where my confusion really comes in is that if the song is in the key
of G does that mean I'm only allowed to play the notes in that scale
The key of a song does not determine which notes you use for the bass-line on a particular chord - the key represents the overall sonority of a song, not all the chords, or the notes they comprise. The chord itself, its function in the music, and its derivation determine that. You're also conflating scale with key. But I'll leave aside those technicalities for now and just talk about playing some decent bass-lines:
Since you're just starting out, the best rule to follow is to build your bass-line from the notes that comprise the chord you are playing behind. In most simple rock, blues and jazz you'll encounter, the analysis amounts to "stacking the 3rds" of the scale indicated by that chord to build the chord on a guitar or piano, and what you can call the "allowed notes" of your bass-line.
If you're playing on a simple C chord, the notes of that chord (the
first two 3rds of the C Major Scale : C-D-E-F-G) will be
C-E-G. So play an arpeggio that matches the groove of the song and is comprised of those notes on that chord, and it will be sound good.
(That simple chord is known as a Triad.) Experiment with changing
their order, working the groove and moving in ascending and
descending directions, but stick to those notes. If you play other
notes, they may or may not work - many variables involved. You can
certainly experiment, but those notes can be considered safe. As @Basstickler explained, 3rds can be an adventure, so 3rds - E in this case - are not always as safe as the others.
If you're playing on a G7 chord, the notes of that chord (the 3rds of the G mixolydian scale G-A-B-C-D-E-F)
will be G-B-D-F. So play an arpeggio of those notes on that chord
and it will sound good. (Such a chord, which upon analysis proves to be a triad with an additional 3rd to bring to the 7th, is called a 7th chord.)
If you move to a D7 chord, the notes of that chord will be D-F#-A-C
(the 3rds of the D mixolydian scale). So play an arpeggio of
those notes on that chord and it will sound good.
If you move to an Am7 chord, the notes of that chord will be A-C-E-G
(the 3rds of the A minor scale ) So play an arpeggio of those
notes on that chord and it will sound good.
If you have a C6 chord, your notes will be C-E-G-A: C-E-G are the first two 3rds of the C major scale, the same triad we already mentioned in the simple C chord, and the A is the 6 in your C6: A is the 6th note in the C Major scale - an extension of the triad of C-E-G. (That chord is called a 6th chord, but don't get bogged down in the hows and whys of the terminology - for now just learn the simple meaning of the chord symbols you encounter.)
If some of this terminology is unfamiliar to you, quite often an easy way is to take a look at the guitar or piano part and see what chords are used and the notes they are built from, or just ask your guitarist or pianist (if you can get away with doing that...) what chord and/or what notes are in the chords they are playing. Most of the time those notes are the notes you will use for your bass-line.
Having said that, to get good at this you should study some basic theory, focusing on the construction of chords and scales. Become proficient enough so that when you see a chord you know what notes comprise that chord, and ultimately what scale it is derived from. It's not really very hard - as a beginning bass player, focusing on roots, 3rds, 5ths and 7ths is all you really need to do. That will put you on the road to becoming a good bass player than can quickly come up with a credible sounding bass-line for most tunes.
Of course you can learn to read bass-lines and reading is important, but I'd venture that 90% of the bass work you hear in rock, blues, pop or jazz is done on the fly by the bass player. The most famous and successful session players - people like Chuck Rainey, James Jamerson, Joe Osborn, Carol Kay, Bob Babbitt, Ducky Dunn... - got there because of their ability to come up with clever, interesting bass lines when they had nothing to work with but a chord chart and a drummer or guitarist.
When I learn something new that's not so simple, at first I'll just learn all the chords and play just roots and fifths of the chords, to get the progression under my fingers and get a feel for the groove. Once I've got that, I will work with other chord tones to create a real bass-line: Go slowly, keep it fun and don't try to do too much at once.
The above should get you started. Again, don't be afraid to experiment when you can afford the risk - that's how you learn. Experimenting with 3rds, and also with throwing in 9ths (Major 2nds), particularly in descending riffs, are good points of departure. You triad has a 3rd, 9th chords are common, and even if it's not a 9th chord, hitting the 9th (2nd) on way back to the root will often add interesting color, especially in blues tunes.
You'll find all of these "rules" constantly being broken in all modern music, because there are no hard set rules in music - just guidelines to help you along. Music is an expressive art form, not a science. So always use your ears - that's only rule we really have. As you progress, you will find your own ways to change it up and make it more interesting. But these guidelines will keep you safe in most situations.
With bass, less is more. If you play simple lines with clean technique, make sure you are in tune, have a good sound and good
time/groove, you'll likely become a very popular bass player.
Here is an excellent book for beginners:
Essential Music Theory for Electric Bass, by Robert Garner