You could even use $r() (the same as $random()) to make it a little shorter.
So your code..
on 1:TEXT:!candy*:#:{
set %candy $rand(1,2)
if (%candy == 1) describe $chan smacks $nick over the head with an iron pan "1,0no candy for you!6"
if (%candy == 2) describe $chan gives $nick a piece of candy
}
Could be shortened to..
on 1:TEXT:!candy*:#: describe $chan $iif($r(1,2) == 2,gives $nick a piece of candy,smacks $nick over the head with an iron pan "1 $+ $chr(44) $+ 0no candy for you!6")
Notice how I had to use the $chr(44) instead of the comma in the color 1,0 part, that was to keep the $iif from treating it as a part of the $iif and therefor failing. The $+'s ofcourse were needed to rebuild 1,0 from 1 $chr(44) 0.
Keep up the coding. :)