Hello, could someone explain to me with an example of how math.random works? please
I am reading the API from the docs and I don’t understand how it works
local number1 = 5
local number2 = 5
print(math.random(number1,number2))
Hello, could someone explain to me with an example of how math.random works? please
I am reading the API from the docs and I don’t understand how it works
local number1 = 5
local number2 = 5
print(math.random(number1,number2))
The function takes in two inputs, the min
and the max
and chooses a number pseudorandomly (meaning not truly random, but made in a way to mimic randomness since with computers, nothing can really be random). For example, setting number1
to 1 and number2
to 10, the function will return a random number in between.
As per the pseudorandom aspect, you can use math.randomseed
to set the seed for the math.random
function to use. If you reset the seed to the same one, it will start generating the random numbers in the same sequence. Read more here.
Yea, “math.random” is between number m to n.
local number1 = 1
local number2 = 2
print(math.random(number1, number2)) --It will print between number 1 to 2
Oh now i understand! So it will always be random between the start and the maximum, how could I do this if I have values of a vector 3 and I only want to use the Z and Y axes?