Still have questions? Join our Discord server and get real time help.
1

# Can someone explain math.random with math.random(tick)? [closed]

Edited 7 months ago

I read about how to make math.random even more random on the Roblox DevWiki, but I don't understand. Can someone translate this into simpler terms? https://www.robloxdev.com/articles/Random-Number-Generation

### Locked by User#21908, aazkao, and RayCurse

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

4
RayCurse 1348
7 months ago
Edited 7 months ago

## Pseudo Random Number Generators

The random number generator in Roblox is called a pseudo random number generator. Pseudo means fake so it quite literally means a "fake random number generator".

## Why Computers Can’t Produce True Random Numbers

Computers cannot produce actual random numbers because they are using the same algorithm every time to produce the random number in question. Computers by their very nature are deterministic machines which basically means it will give the same answer if the same input is given.

## Random Seeds

Computers generally use some sort of algorithm in order to produce these random numbers which is why they are pseudo random number generators. In theory, it is completely feasible to reverse engineer the process and predict the next "random" numbers with complete accuracy. These algorithms produce sequences of numbers based on a seed. If the same seed is given, the algorithm will always produce the same sequence of numbers (just like how a Minecraft word generation seed will always produce the same world).

The problem that the article is outlining is that without setting the seed of the random number generator, you'll get the same sequences of numbers every time. In order to make the pseudo random number generator reasonably random, you can call math.randomseed(). math.randomseed() simply takes in a number as input and sets it as the seed. You need to make sure you set the seed to something different every time. You can do this by giving math.randomseed() the time as input because time is a constantly changing value. You can pass in the value of tick() which returns how much time has passed since UNIX epoch like so:

math.randomseed(tick())


## True Random Number Generators

It is possible to produce true random numbers (not perfectly random but extremely close) by observing factors such as thermal and atmospheric noise. This site does exactly that and uses atmospheric noise in order to produce random numbers. It’s appropiately called a “true random number generator” because it produces authentic random numbers. Even if it’s not perfectly random, it can’t be predicted at all to any degree.