generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: This has to be wrong

Previous Thread :: Next Thread 
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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 is not online. LuluPls
Joined: 23 Aug 2010
Total Posts: 1221
17 Nov 2017 11:54 AM
Works fine for me.
Report Abuse
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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 is not online. 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
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
17 Nov 2017 12:05 PM
Just makes it 32 instead of 34 :/
Report Abuse
LuluPls is not online. LuluPls
Joined: 23 Aug 2010
Total Posts: 1221
17 Nov 2017 12:08 PM
post the entire script
Report Abuse
Extuls is online. 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 is not online. LuluPls
Joined: 23 Aug 2010
Total Posts: 1221
17 Nov 2017 12:12 PM
Lol, thats probably what he's doing @extul
Report Abuse
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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 is online. 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
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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 is online. 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
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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
kjake43607 is not online. kjake43607
Joined: 11 Apr 2011
Total Posts: 1100
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
EmilyBendsSpace is online. EmilyBendsSpace
Joined: 29 May 2017
Total Posts: 17
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image