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

Math.random not working???

Asked by 9 years ago

so I have been having some problems with the coding for my game, up until today the math.random works fine but for some reason its not working

print(math.random(100))

Every single time I do it I always get the same exact number and im pulling hairs

Yes I have tried the code on a different place, and I have reinstalled studio, advice please

0
Are you setting the seed somewhere? The same seed will result in the same numbers. Perci1 4988 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

This has to do with the way the code works. Whenever you run the code at a specific time past starting it in studio, it will have the same results. You will only ever notice it producing duplicates if you run it without delaying calling it, i.e. the wait function. Don't worry about it, it's working fine. If you do want to produce different results for testing purposes, then delay before you search for random numbers at the beginning of your script.

0
I don't think this is right - running math.random() in studio will give random numbers just as it will online. Unless I'm misunderstanding. Perci1 4988 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

try, math.random(1,100) < says pick a whole number from 1,100.....

0
It is still the same outcome QuantumToast 261 — 9y
0
odd Abstract_Life 65 — 9y

Answer this question