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

Math.random isn't being random?

math.randomseed(tick())

local rand = math.random(1, 3)

print(rand)

That's it, it prints "3" every time instead of 1, 2, or 3.

1 answer

See my answer here: https://scriptinghelpers.org/questions/43181/is-it-just-me-or-has-mathrandomseed-stopped-working

Quick answer: always ignore the first math.random(), like so:

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

print(math.random(1, 3))

4 comments

0

I see, did it change or something? I remember it working differently the last time I used it. Thanks by the way.

0

The need to skip the first math.random() has been in place for years. If you print the first math.random(), you'll find that it is different for different seeds - just not by much.

0

I recommend using math.randomseed(os.time())

0

@craftsmashbuild Tick revolves around a user's time zone, while Os.Time revolves around the general time; Tick will still function as is, even if it's not used in a LocalScript if that's what you mean. c;

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