I want two numbers (18 and 64).
I'm trying to get a number inbetween them (18-64), and generate it randomly.
Help?
I think you're talking about math.random()
.
Here is an example of how to do this:
num1 = 18 num2 = 64 randomnumber = math.random(num1, num2) --Gets a random number between num1 and num2. print(randomnumber) --Print result
http://wiki.roblox.com/index.php?title=Random_numbers&redirect=no
You're looking for math.random. You'd use it like this:
local num = math.random(18, 64) print(num)
This would print a number between 18 and 64. If you want it to be different each time it runs, though, you'll need to use a seed. A commonly used one is tick()
.
math.randomseed(tick()) local num = math.random(18, 64) print(num)
This would be more random than the first example. Hope this helped.
Well, I asked if you could be in-depth about this. But I will attempt answering it anyway :)
Essentially, all you need to do is create two variables of math.random(). Heehee.
local x = math.random(18,64) local y = math.random(18,64)
These two variables store randomly generated numbers between 18 and 64. You can use the variables X and Y for whatever you need past this point.