|
| 22 Apr 2017 05:22 PM |
| I have this script which takes a prints a random value using math.random(1,4) every second. However it keeps printing 4, and doesnt change! |
|
|
| Report Abuse |
|
|
NilLogic
|
  |
| Joined: 08 Apr 2016 |
| Total Posts: 1369 |
|
|
| 22 Apr 2017 05:22 PM |
I think the link(s) below may be of use to you:
Join the fan group: https://www.roblox.com/My/Groups.aspx?gid=3201548 |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2017 05:24 PM |
Call `math.randomseed(tick())` to seed the pseudo-random generator and call math.random once after it. After that you should start getting "random" numbers.
The reason you are getting the same outcome over and over is because math.random technically isn't random and operates on a seed that doesn't change by default.
|
|
|
| Report Abuse |
|
|
Oryxide
|
  |
| Joined: 09 Jul 2015 |
| Total Posts: 647 |
|
|
| 22 Apr 2017 05:46 PM |
| A mod should just pin a thread relating to Math.Random. |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2017 05:46 PM |
No, they really shouldn't. This has been explained countless times already and it's all over the Internet.
|
|
|
| Report Abuse |
|
|
|
| 22 Apr 2017 05:51 PM |
| Nope, math.random doesn't even make anything random |
|
|
| Report Abuse |
|
|
|
| 22 Apr 2017 06:00 PM |
math.randomseed( tick() ) math.random()
--should clear up results after getting that first ugly one out of the way |
|
|
| Report Abuse |
|
|