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 » Scripting Helpers
Home Search
 

Re: Table Help?

Previous Thread :: Next Thread 
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
26 Sep 2014 05:03 PM
local ids = {142295308, 142281425, 145144013, 168983825 }
local music = ids[math.random(1, #ids)]


Works well in studio, but on online mode it picks the first id, why?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
26 Sep 2014 05:05 PM
Random isn't random.


Random uses some obscure formula to decide a number.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
26 Sep 2014 05:07 PM
^
That doesn't explain why it only picks the first, though. Try this:

local ids = {142295308, 142281425, 145144013, 168983825 }
math.randomseed(tick())
local music = ids[math.random(1, #ids)]
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
26 Sep 2014 05:10 PM
Still...

Similar seeds produce similar results.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
26 Sep 2014 05:11 PM
And tick() will be different every time you use it.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
26 Sep 2014 05:13 PM
I would think the first number would somewhat similar result within a span less than 100 or so from a somewhat distance difference of two ticks regardless.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
26 Sep 2014 05:15 PM
math.randomseed(math.random(math.huge))

...?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
26 Sep 2014 05:17 PM
I think math.huge is a negative number so that would error, actually.

And I'd think the number selected will always be the same even if you did it right from my knowledge of how random works.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
26 Sep 2014 05:19 PM
It isnt random as far as I know. ( 9^9^9 )
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
26 Sep 2014 05:20 PM
random > negative*
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
26 Sep 2014 05:21 PM
math.randomseed(math.random(tick(), math.huge))

Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
26 Sep 2014 05:22 PM
By that, I mean it IS greater than 0...


But it's read as a negative number.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
26 Sep 2014 05:23 PM
I'm pretty sure a new seed is given every time a new server starts.
So OP shouldn't have that problem every time he tests.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
26 Sep 2014 05:25 PM
for i = 1, 100 do math.randomseed(math.random(math.huge, tick())) print(math.random(1,10)) end

>

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

cmdbar so tick didnt wait
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
26 Sep 2014 05:29 PM
@vlek
That happens when you set the seed before every single iteration of the loop.
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
26 Sep 2014 05:58 PM
how would i apply this with the table?
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
26 Sep 2014 06:36 PM
Try what I posted first.
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
26 Sep 2014 07:46 PM
You can do what apple did and make a random music selector that isn't technically 100% random by making sure it doesn't choose two songs in a row.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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