Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Printing random numbers in a certain range of numbers?

The concept sounds easy but I have no idea where to start. Example

printed a random number between 1 and 10

1 answer

Okay, firstly this is not a request site.

So, you will want it to actually be random, so we add this line.

math.randomseed(tick()) -- Generate random seed.
math.random() -- Throw out first not-so random number, which is a known limitation of lua.

Now, we want to get a number within a range of other numbers, for example, between 1 and 10. To do this we will use math.random() and we will store it in a variable called range.

range = math.random(1, 10)

Now we will print it to the console.

print(range)

Full Script;

math.randomseed(tick())
math.random()

range = math.random(1, 10)
print(range)

If you would like any more help, don't hesitate to ask. If I solved your problem, please hit the accept button of this answer.

Good Luck!

4 comments

0

I dont understand how to not "request" something LOL. you are REQUESTING something no matter what if you are asking something. lol

0

whether you are requesting an answer or an example you are requesting something no matter what lol

0

No. The rule is that you must try to make it yourself, then if it fails, you post the code here, explain your problem and what you have done to fix it. Theoretically, I shouldn't have even posted my answer. I'll now report this post as to discourage it from happening any further.

0

No. The rule is that you must try to make it yourself, then if it fails, you post the code here, explain your problem and what you have done to fix it. Theoretically, I shouldn't have even posted my answer. I'll now report this post as to discourage it from happening any further.

This discussion is preserved as it was. New answers, comments, and votes are closed.