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

Why does math.randomseed(tick()) return an identical seed in two separate identical scripts?

Asked by 5 years ago

math.randomseed(tick()); print(math.random(30000))

I have these two lines of code in two separate scripts, but every time, without fail, they both print the same number. I even tried typing random numbers inside each tick(), but nothing improved. What am I doing wrong here, and how can I fix it? Thanks!

0
Multiple randomseeds with the same value will always produce the same number sequence. Even with just one, Randomseed only uses the integer part of the number, so everytime it runs, it’s effectively starting with the same number.   ABK2017 406 — 5y
0
You could try “math.randomseed(tick() * 1000)” ABK2017 406 — 5y
0
You could also use NextInteger(min, max) or NextNumber(min, max) ABK2017 406 — 5y
0
Thanks so much - I'll try that out! OnlineOne 0 — 5y
View all comments (2 more)
0
I usually use crazy equations in my randomseeds that I just think of while I am doing stuff. I also usually use math.random() inside of the math.randomseed(). Not sure how effective that is but it's what I've been doing and it seems to work. joritochip 705 — 5y
0
You only need to run 'math.randomseed' once for the entire place and it'll be set for all scripts chess123mate 5873 — 5y

Answer this question