Tutorial to generate random number

Started by Ergosphere on Sat, 09/11/2021 - 22:09

Topic category: User side tutorials

Last seen on 13:10, 26. Sep 2021
Joined Sep 2021

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Tutorial to generate random number
Sat, 09/11/2021 - 22:09

You can use the code below the generate a random number. The top function is for when your minimum is 1. The bottom is for any other scenario.

For each function interchange 15 for your maximum number and change 5 for your minmum in the bottom one.

In code form the formula looks like this: 

(Math.random() * (maximum - minimum + 1)) + minimum