This question has been asked before, I recommend reading these threads for a better explanation. In simple terms, computers don’t have the ability to generate “real” random numbers, so they take seeds.
It’s a function that creates random numbers from a seed. It’s just math.random() but instead of giving it a range of values you give it a seed value. If you give it the same seed value it returns the same number.
It’s like saying 2+3 always equals 5. If you gave math.randomseed() a value of 5 it will always return the same value when you give it 5.
Computers can’t generate true random numbers so instead they always rely on some function to generate their “random numbers”. All math.randomseed() is, is a big complex function that takes one input and gives one output.
Scripts like this are the reason you should avoid math.random altogether. In a perfect world, code like this would only run once when the game starts up. In reality it might run every time a script is cloned, or even in a loop somewhere if you inserted an unfortunate free model.
Any script can call math.randomseed and mess up the global seed for all scripts, resulting in not-so-random values. You should use Random.new() in cases where randomness is important.
math.randomseed doesn’t actually return anything, it a void function. All that calling it does is it influence math.random() in your script
math.randomseed(1)
print(math.random(1, 100)) -- prints 97
math.randomseed(2)
print(math.random(1, 100)) -- prints 26
math.randomseed(1)
print(math.random(1, 100)) -- prints 97
The reason that you see a lot of people doing math.randomseed(tick()) is because since the value of tick() always counts up, and if you put it in the beginning of your script, every time the game starts and the script runs and the random seed is changed, you get different numbers from math.random() every new time the game starts.
If you didn’t put math.randomseed(tick()) in the beginning of the script, every new time you start the game, math.random(1, 3) will always return the same number.
( tick() returns the amount of seconds since the start of 1970 )
Calling math.randomseed() is meant to change how the math object generates pseudo-random numbers. You get random numbers by calling math.random(number min, number max). I also don’t recommend calling math.randomseed() like you posted above as it would cause the same map to be picked over and over, just let roblox do the job for you.
math.randomseed() shouldn’t really be used unless you have a very specific need to set the seed for random number generation. If you really had to, you could use the function to make sure the seed was different. In general: there really isn’t a scenario I imagine where you need to call this function. Just use the Random class if you absolutely need to change the seed and such.
math.random is a function that Just Works. It has no prior setup, so you can just type it where you need to use it. Having to look up how to use the Random datatype and assign a variable beforehand every time, and also needing to learn how to use NextInteger and NextNumber along with the purpose of the Clone function should one need it, is simply not an elegant solution in contrast to the ease of using the original function.
</rant>
That said, if it’s important as you mention then it does make sense to learn to use the new API.