Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get different random numbers at the same time?

Asked by 5 years ago

So I'm trying to use math.random() to generate a different random number for each player when they load into the game

wait(5)
math.randomseed(game:GetService("RunService").Stepped:wait())

rando = math.random(0,100)
if rando > 50 then
    script.Parent.Value = "Thing1"
elseif rando < 50 then
    script.Parent.Value = "Thing2"
end

I put this inside a script inside a string value. I am trying to generate a 1/2 chance. However just about all players get the same value everytime. I think it has to do with the seed since its the same seed for every player, since all the random numbers are generated at once. I tried using tick(), but since a random number is generated for each player at the same time, each seed is the same. Any ideas?

0
the "math.randomseed" above was something from another post on the roblox forums that suggested it. NickDestroyer123 12 — 5y
0
randomseed uses the same generation algorithm as the Random object now -- so, there's not really any need for tick(); if you feel like everyone is getting the same value, maybe try the Random class since it takes double seed. [https://wiki.roblox.com/index.php?title=Random] SummerEquinox 643 — 5y

Answer this question