Exported variables are available to child processes, unexported variables are not.
Code:
[moy@becket ~/test/foo]$ cat > foo.sh << EOF
> echo \$foo
> EOF
[moy@becket ~/test/foo]$ chmod u+x foo.sh
[moy@becket ~/test/foo]$ cat foo.sh
echo $foo
[moy@becket ~/test/foo]$ foo=abcd
[moy@becket ~/test/foo]$ ./foo.sh
[moy@becket ~/test/foo]$ export foo
[moy@becket ~/test/foo]$ ./foo.sh
abcd
[moy@becket ~/test/foo]$