Random number generator command

Asked Apr 3, 2024·3 replies·Last activity 2 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

I'm kinda new to moding and don't really understand the more complicated mods like generating a random number. I want to add a command that says. (@user) is 0-100% smart. and I don't know how the random number generation works

3 replies

here u go ^^

js
$(user) is $(eval Math.floor(Math.random()*101))% smart.

Hi, how would you change the code to make it say big or small depending on the number generated?

based on "big" and "small" i'm guessing u wouldn't want a zero, so the random statement would be a little different... something like this...

js
$(user) is $(eval let r=Math.floor(Math.random()*100)+1;`${r}% ${r>50?`big`:`small`}!`)

p.s. this will say "<username> is <number>% big!" if the number is above 50 and "<username> is <number>% small!" if 50 and below