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

How do I improve my random script?

storage = game.ReplicatedStorage
backpack = game.Players.LocalPlayer.Backpack
math.randomseed(tick())

storage["Kagune" .. tostring(math.random(8))]:clone().Parent = backpack

This local script in starterpack chooses a random local script from Replicated Storage and clones it into the players backpack however it seems to be choosing the same random local scripts for everyone. Is there anyway to improve this script to make the randomisation better?

1 answer

✓ Accepted answer

If the script is given to everyone at the same time, they're all going to be seeded with the same tick. If they're on the same kind of computer in the same time zone, that means the numbers you get out of math.random are going to be the same.


Just don't see seed -- you don't need to.


Purely random numbers are unpredictable. Most of the time, there will be repeats between items -- if there weren't, you don't have a very good random number generator.

If you don't want it to actually be random, e.g., you don't want many/any repeats, you need to actually write code to make that happen -- a good random number generator won't give you that.

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