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

Math.random not working???

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

1 comment

0

Are you setting the seed somewhere? The same seed will result in the same numbers.

2 answers

✓ Accepted answer

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.

1 comment

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.

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

2 comments

0

It is still the same outcome

0

odd

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