use $lower bcz of "D" mabe that won't work with chr 100
and u have to stop the code after the check of numbers by adding halt, return, or if/else, orelse the loop will continue the execution

Code:
on *:text:!roll *:#:{
  tokenize 100 $lower($2-)
  if ($1-2 !isnum) msg # ERROR: Wrong format.  Example: !roll 3d6
  else {
    var %n $1,%d $2
    while (%n) var %r %r $r(1,%d),%n %n - 1
    msg # %r
  }
}