Thanks a lot Blessing. I'm guessing !ticket roll closes the raffle.

I currently have the code you posted plus this one

Code:
on *:text:!ticket roll:#:{
  if ($nick == forgottenheroes) {
    if ($hget($+(tickets.,#))) {
      var %i = $r(1,$hget($+(tickets.,#),0).item)
      msg # The winner is $hget($+(tickets.,#),%i).item
      ; The next line frees the table (all data in it is gone)
      hfree $+(tickets.,#)
    }
    else msg # Sorry $nick there is no entries at the moment. 
  }
  else msg # $nick Only Mods can use that command.
}


But when I added in your code It not longer says Sorry there is no entries. It just says nothing. and if I do !ticket on then type !ticket roll it just says the winner is 0 since nobody entered.

My old script allowed users to do !ticket once and it would enter them into the raffle just 1 time only. Then I did !ticket roll to pick a winner.

I'm gonna have to make it more neat looking so I can do !ticket on and it lets ppl know the raffle is now accepting points. Then I can do !ticket off to let the users know the raffle has ended and not accepting any new entries. Then I can do !ticket roll it gives the winner and clears the names.