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

How Can you randomize a value?

All I want to do is randomize a value that I have. but I don't know how to randomize something in script.

1 answer

✓ Accepted answer

I will help ya, NewRobloxhighschool (once more :P)

Alright, what you want is the math.random()

Let's take a basic look at the math.random().

math.random() will output a random number, that's located between 0 and 1 by default. For example:

print(math.random()) -- > a value between 0 and 1, normally with a lot of decimals, e.g. >0.1827312488124.

But... there's more! We can change the extremes. In this case, let's make the number to be between 50 and 750. In this case, the math.random() would be math.random(50, 750), and the output would be a number between 50 and 750.

NOTE: When you set extremes for a math.random(), unless any of the extremes has decimals on it, the output number will never have decimals.

Example:

print(math.random(50, 750)) -- > a value between 50 and 750, with no decimals, e.g. >634

If you want to learn more deeply about math.random(), follow this link on ROBLOX wiki: http://wiki.roblox.com/index.php?title=Random_numbers And there's also a similar thing, called math.randomseed(), but that, you gotta check by yourself in the link there up.

If you find this answer correct, which should happen, please mark as correct, and have a good scripting as always ;)

2 comments

0

Thanks again!

0

No worries, if you need anymore help, talk with me, because I can help you. Btw you can always add me on ROBLOX: @OfcPedroo

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