|
| 04 Aug 2016 01:47 PM |
| Recently in all of my scripts, whenever I use math.random() along with math.randomseed(tick()) it usually ends up picking the same thing EVERY TIME. I ran the code over and over 100+ times and it still picked the same thing over and over. How do I fix this? |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2016 01:51 PM |
while wait(1) do print(math.random(1, 100)) end
|
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 04 Aug 2016 02:00 PM |
| it practice it is still very random |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2016 02:00 PM |
| Can anyone else answer the question I stated? |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 04 Aug 2016 02:04 PM |
Have you tried it in online mode? Also make sure you're not doing something like this:
for i = 1,10 do math.randomseed(tick()) print(math.random()) end
because tick will return the same value and every number will be the same because you are seeding them with the same number. |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2016 02:05 PM |
| I am running the randomseed function at the beginning of each iteration of the game loop. Each game takes a little over a minute to 2 minutes. |
|
|
| Report Abuse |
|
|
|
| 04 Aug 2016 02:06 PM |
| And yes, I've tried in studio and online mode. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 04 Aug 2016 02:07 PM |
seed once at the start of the script.
run this: math.randomseed(tick()) for i = 1,10 do print(math.random()) end
I assure you it will print 10 different numbers. If you seed at the start of the script and keep getting the same random numbers it's something you're doing. |
|
|
| Report Abuse |
|
|