John wants to leave a note for Fred, so:
<John> !note Fred message goes here
Your script then creates the variable
%notenick.#channel.John Fred
%notemsg.#channel.John message goes here
Then Fred enters the channel, and it checks for %notenick.#channel.Fred which doesn't exist. The next time John enters the channel, %notenick.#channel.John does exist, however the contents of that variable are filled with Fred, so since Fred != John, no message is left. The only way a message could be triggered would be if John left a message for himself, but you're preventing that by checking if $2 is online.
When creating variables, you'd use $2 instead of $nick without verification of $2 being legit. You might want to create a list of approved nicks who can have messages left for them.
I tested leaving a note for $compress(
versions.txt) and it didn't compress that file, so it's probably safe to use $2 here without checking that it's a legit nick. You should have the script do a test to make sure $2 doesn't contain characters not valid in a nick.
//if ($remove($2,_,-,\,[,],$({),$(}),^,`,$(|)) !isalnum) Msg $chan $2 not a nick, no note saved.
You also have potential for a build-up of bogus notes that will never be deliverable. You could fill $ctime into your notenick or create a %NoteTime variable so you can use that to delete variables reaching a certain age. If the script is working, you shouldn't need to check that the value of the variable is the same as the word used to create the variable name, just that it exists.
Also, the way things are now, Fred has no way to know who left the message for him, unless the sender includes in the message. And even worse, the sender could false flag:
<John> !note Fred This is Mary, I love you!
More reliable would be using "Message from $nick $+ : $3-" instead of just "$3-"
Also, your code for ON JOIN and ON TEXT are identical, both before and after your fix. You could streamline that code into an alias, then have the 2 events just call the alias.
on *:JOIN:#:{ newalias }
on *:TEXT:*:#:{ newalias }
The alias will still know the values for $chan and $nick.
Also, when the script is fixed, your ON TEXT which triggers for :*: checking if there's a message to display - doesn't activate when someone leaves a note, because those events are trapped by the 1st ON TEXT event. Because you're using ON JOIN, your 2nd ON TEXT would never get triggered unless someone enters channel with their alt-nick and changes nick once they're in channel. For those cases, you could check the ON NICK event to show the message then, instead of waiting for them to trigger the TEXT event.
If you do use ON NICK, your code is no longer the same, because ON NICK would need to inspect $newnick instead of $nick. You can adjust for that by doing things like:
if (variable == $nick )
becomes
if ( variable == $iif($event == NICK,$newnick,$nick) )
or
if ( variable == $iif($event isin TEXT JOIN,$nick,$newnick) )
You could have quickly caught your error by inserting a debug message into your script. At the top of the JOIN event, echo your IF statement, making sure that parenthesis aren't touching anything else:
echo -s $script $scriptline if ( %notenick. [ $+ [ $chan ] ] [ $+ [ . ] ] [ $+ [ $nick ] ] == $nick )
... would have shown you why it wasn't triggering your message.