|
| 17 Nov 2017 11:52 AM |
Number = math.random(1,30)
ITS ALWAYS 26, i tried 7 times in a row. same output. i have to have done something wrong here^ |
|
|
| Report Abuse |
|
|
LuluPls
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1221 |
|
| |
|
|
| 17 Nov 2017 11:55 AM |
| I changed 30 to 40, and now its constantly 34? either im the most unlucky person. or theirs something wrong |
|
|
| Report Abuse |
|
|
Cyrakohl
|
  |
| Joined: 09 Nov 2014 |
| Total Posts: 3197 |
|
|
| 17 Nov 2017 11:56 AM |
| Before you use math.random put math.randomseed(tick()) |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:05 PM |
| Just makes it 32 instead of 34 :/ |
|
|
| Report Abuse |
|
|
LuluPls
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1221 |
|
| |
|
Extuls
|
  |
| Joined: 02 Jan 2009 |
| Total Posts: 5557 |
|
|
| 17 Nov 2017 12:10 PM |
"Number = math.random(1,30)"
If you're printing that variable 'Number' over and over again, then of course it's the same number. That's all I can imagine this to be.
|
|
|
| Report Abuse |
|
|
LuluPls
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1221 |
|
|
| 17 Nov 2017 12:12 PM |
| Lol, thats probably what he's doing @extul |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:17 PM |
| im test playing over and over so unless the script saves variables from different test plays and never changes then i dont think im that dumb. |
|
|
| Report Abuse |
|
|
Extuls
|
  |
| Joined: 02 Jan 2009 |
| Total Posts: 5557 |
|
|
| 17 Nov 2017 12:21 PM |
There's your issue. math.random() isn't *actually* random. Roblox is going to release a new random class "soon" which is going to be way more efficient. But for now, do this:
math.randomseed(tick()) for _ = 1, 10 do math.random() end Number = math.random() print(Number)
|
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:21 PM |
| right, im convinced my studio is broken. i measure the magnitude between an origin part to 4 parts. each part is 10 studs away from the origin. i measure the magnitude for each one. and they are all between 4.5 to 5.6, all different order from the way i set them. I hate life |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:25 PM |
| @Extuls i changed your for loop from 10 to 30 assuming that 30 was the max range of the possible randomized number. and now its printing single digit decimals. is this right? |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:27 PM |
| I feel im being really stupid now. i recon this is a plain obvious bug to fix but im to stupid to see it |
|
|
| Report Abuse |
|
|
Extuls
|
  |
| Joined: 02 Jan 2009 |
| Total Posts: 5557 |
|
|
| 17 Nov 2017 12:28 PM |
Why are you assuming 30 is the max? Don't assume things. Go research the facts.
The decimals is an error on my part. Forgot to add the arguments to math.random(). Should've been this:
math.randomseed(tick()) for _ = 1, 10 do math.random() end Number = math.random(1, 30) print(Number)
|
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:32 PM |
| No, 30 is the max number i need for my script. sorry shoulda made that more clear. |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 12:58 PM |
Thanks guys i owe you. i finally got it working.
the random number was how much extra the SpinTheWheel spins so that its different each time
the magnitude problem i solved. the colour would land on green and it would output Red.
game: https://www.roblox.com/games/1151342371/Slots
thanks for helping me fix it ;) |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2017 06:03 PM |
FYI, don't trust math.random() in studio. The studio app itself reseeds it and you get a very small number of values out. But the code will work as expected once published.
|
|
|
| Report Abuse |
|
|