You appear to misunderstand how else statements work, so here's few comments to explain it:

Code:
if ($2 == $null) { ; if $2 doesn't exist do this. }
elseif ($2 != %guessnumbernum) { ; if $2 isn't the correct number }
else { ; the only possibility is that it IS the correct number, otherwise the previous elseif statement would work, and this part of the script would never be reached. }