For the benefit of mitch21236 In the original script, extra brackets, $chan and use of set variable.
on *:JOIN:#: { var %rand $r(1,2) if (%rand == 1) { msg # $nick, Hey $nick } if (%rand == 2) { msg # $nick, Hello $nick } }