Hi! I have been researching on here for a while on how to make a command for a random percentage within a specific range to be displayed when triggered in chat, but I can’t seem to get it right… So I came to ask the experts!
Majority of commands I see are for a random number ranging from 1-100, but how can it be changed to be from 60-100 only? Or 80-200? etc.
Sorry if the answer is obvious, just wondering the best way to achieve this. Thank you in advance!
It’s not too far off the other type of commands you might have seen.
As explained here, you can generate a number between two values — both included — like this:
Math.floor(Math.random() * (max - min + 1) ) + min;
With that in mind, here’s how you can write the command to fit your needs, and you just need to replace MIN_VALUE and MAX_VALUE by the numbers you want:
$(eval min = MIN_VALUE; max = MAX_VALUE; Math.floor(Math.random() * (max - min + 1)) + min;)