Yes, it's a problem that nobody has status during the JOIN event. You could trap the :OP: event when someone is given that status, or have a timer wait a few seconds, passing parameters to it only if they can't be evaluated, such as not passing $1-
/timer 1 2 my_alias $chan $nick

You also have a problem in that the 'return' at the end of the Sybian line is not part of the conditional command, so it executes regardless whether the if() is $true or not. To have it part of the conditional command, you must enclose all the conditionals inside curly braces

if ($rand(1,2) == 1) echo -a displays only if rand is 1 | echo -a always displays
if ($rand(1,2) == 1) { echo -a displays only if rand is 1 | echo -a also displays only when if() is true }