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: randomization

Previous Thread :: Next Thread 
Lucargia is not online. Lucargia
Joined: 25 Jan 2013
Total Posts: 371
11 Sep 2015 09:12 PM
local flavor = {"item1", "item2", "item3", "item4", "item5", "item6", "item7", "item8", "item9", "item10"}
function clicked()
local colorChoose = math.random(1, #flavor)
Workspace.ORDER1VALUE.Value = flavor[colorChoose]

For some reason this doesn't work, it works in studio and not in-game, in-game it goes in some order everytime.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
11 Sep 2015 09:13 PM
At the top of the script:
math.randomseed(tick())


Muad'Dib
Report Abuse
Lucargia is not online. Lucargia
Joined: 25 Jan 2013
Total Posts: 371
11 Sep 2015 10:19 PM
It now just appears to be repeating the same value over and over.
Report Abuse
Lucargia is not online. Lucargia
Joined: 25 Jan 2013
Total Posts: 371
11 Sep 2015 10:32 PM
By value I mean "item", more specifically item5
Report Abuse
Lucargia is not online. Lucargia
Joined: 25 Jan 2013
Total Posts: 371
12 Sep 2015 02:22 AM
gagagagagaga
Report Abuse
DefineCode is not online. DefineCode
Joined: 09 Apr 2012
Total Posts: 1060
12 Sep 2015 02:46 AM
local Reverse = function(Number)
return tonumber(tostring(Number):reverse())
end
math.randomseed((math.random()*2) * Reverse(math.floor((tick() ^ 2) / 2e6) / 1000)^2)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
12 Sep 2015 03:08 AM
The only reason it would return the same exact number every time is if you were setting the seed every time you called math.random instead of calling it once.

If it returns the same number a few times in a row(2 - 5) then returns a different number that is still random numbers.

Random does not mean different each time.

Muad'Dib
Report Abuse
Lucargia is not online. Lucargia
Joined: 25 Jan 2013
Total Posts: 371
13 Sep 2015 12:20 PM
Yeah that's basically what it does. Is there any way to make it more random however?
Report Abuse
Emperoar is not online. Emperoar
Joined: 06 Aug 2010
Total Posts: 382
13 Sep 2015 12:32 PM
game.Workspace? not Workspace


~Emperoar~
Report Abuse
Emperoar is not online. Emperoar
Joined: 06 Aug 2010
Total Posts: 382
13 Sep 2015 12:33 PM
script.Parent.MouseButton1Down:connect(clicked)


~Emperoar~
Report Abuse
Lucargia is not online. Lucargia
Joined: 25 Jan 2013
Total Posts: 371
13 Sep 2015 12:43 PM
^ That wouldn't make much of a difference. It works all the same.
Report Abuse
DefineCode is not online. DefineCode
Joined: 09 Apr 2012
Total Posts: 1060
13 Sep 2015 06:08 PM
My code above is able to generate a new different seed with literally no time difference :/
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