# D20 custom responses according to whats rolled

I’ve been playing around and trying to figure out how to have custom responses according to specific numbers rolled. Example:
1 = \$(user) rolled a nat 1 and died.
2-19 = \$(user) rolled a _
20 = \$(user) rolled a nat 20, critical hit!

I have been using eval rng and trying to input responses via if and else but not quite getting it. This is the base command im working with, but im more than open to change it:

\$(user) rolled a \$(eval Math.floor((Math.random() * 20) + 1))

I also tried this based off of reading things but couldnt get it to work:

\$(eval var a = (Math.floor(Math.random() * 20)); if (a=20) { var s = " \$(user) rolled a nat 20, critical succuess! “; } if (a=1) { var s = " \$(user) rolled a nat 1 and died.”; } else { “\$(user) rolled {r}.”)

``````\$(user) rolled a \$(eval d=Math.floor(Math.random()*20)+1;s=``;if(d==1){s=` and died.`};THIS_PART;if(d==20){s=`, critical hit!`};NAT_HERE;d+s)
so for “THIS_PART” u can add other numbers too, not just 1 and 20 like this does… individual numbers can be done by following the pattern of `if(d==1)` and `if(d==20)` and if u want a range, u can do `if(d>=2&&d<=19)` for all of 2 to 19 or `if(d>=5&&d<=9)` for 5 to 9 etc…
``if(d==1||d==20){d=`nat `+d}``