Discord
Login
Community
DARK THEME

help me with random numbers

i just need to make it into a variable and need help

Wdym

Here's a simplified explanation on the random numbers and how you would use them:

"random.next()" is an number between 0 and 1 ( up to about the 18th decimal place as of my knowledge ) . It really is that simple.

"random.nextInt(variable)" would be a number between 0 and ' variable ' minus 1.

For example you could use 'random.next()' like this:

local v = random.next() // defining the variables value with ' random.next() ' which again, will return a number between 0 and 1. 
print(v)

or if you wanted a number over 1:

local v = random.next()*10 // would still randomly return 0 though.
print(round(v))

// mind you using nextInt would give you the same results with less complication but just in-case you wanted to use this method of 'random.next()' this is how you would.

Using 'random.nextInt(v)' would be a slightly different story:

local maxValue = 10
print(random.nextInt(maxValue)) // this would return anything between 0 and maxValue ( 10 ) minus 1. 

There is another one called " random.seed() " but it is alot more complicated and I personally don't see a practical use for it but if you want to learn on it go to the documentation.

There are also libs you could use that do all of this for you. Such as random extended by mythril | https://microstudio.dev/i/Mythril/randomextended/

Thanks so much :)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community