Okay so I want to use math.Random to give me a number between 1,2 so I did math.random(1, 2) So for example if I wanted the script to be like if Random == 1 then print("Hi") if Random == 2 then print("Hello") Ik this doesn't work you get the point
number math.random ( number m = 0.0, number n = 1.0 )
math.random returns a value between m and n. To store the value for later use, you would equate a variable to the result:
local RandomNumber = math.random(1,5) -- this will return a number between 1 and 5
To enhance the "randomness" of the numbers returned, you could use:
void math.randomseed ( number x )
math.randomseed(tick())
As for using the random number returned by math.random(m,n), that depends on how you are planning on using it. If you want to simply check what number was returned, you would use an 'if' statement:
local RandomNumber = math.random(1,5) if RandomNumber == 1 then -- Do something elseif RandomNumber == 2 then -- Do something else end
local randomNumber = math.random(1,2) print(randomNumber)
I know that, but I am trying to do something more complicated as for example
math.random(1, 2) if math = 1 then game.workspace.sound.playing = true if math = 2 then game.workspace.sound2.playing = true something like that
So to do this math.random requires a minium and a highest number all need to be whole numbers to use this just put math.random(1, 100) or what ever you want where you want the number to be