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: math.randomseed(tick()) doesn't working?

Previous Thread :: Next Thread 
ORZpasserAtw is not online. ORZpasserAtw
Joined: 20 Feb 2011
Total Posts: 2365
07 Jul 2016 03:36 AM
for i = 1,3 do
math.randomseed(tick())
repeat
math.randomseed(tick())
LPN1 = math.random(1,5)
math.randomseed(tick())
print (LPN1)
wait(0.1)
until LPN1 == 3
end

it keep printing 2

I want try to stop when LPN1 == 3
Report Abuse
kangerujack is not online. kangerujack
Joined: 08 Nov 2009
Total Posts: 690
07 Jul 2016 03:37 AM
Declare math.randomseed() at the very beginning of your script once.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
07 Jul 2016 03:59 AM
Once is enough.


-=[ RAP: 347,235 || DurstAuric; the narb of ROBLOX ]=-
Report Abuse
MathematicalPie is not online. MathematicalPie
Joined: 19 Aug 2014
Total Posts: 28
07 Jul 2016 04:40 AM
Do you even know the use of randomseed?

1) As the person said above, you pretty much only need to call it once in most cases.
2) You realise you're waiting .1 of a second right? That's a tiny amount to wait for and occasionally can cause very weird outputs with math.randomseed.

I suggest you only call it once and just keep calling math.random(1,5) until you get the desired number (which in your case is 3)

Thanks,
MathematicalPie
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
07 Jul 2016 04:46 AM
Are all those steps even necessary? It's really simple to capture a number.
math.randomseed(tick() * math.random()) -- Just to be sure.
local Number = nil
repeat wait()
Number = math.random(1, 5)
until Number == 3


-=[ RAP: 347,259 || DurstAuric; the narb of ROBLOX ]=-
Report Abuse
MathematicalPie is not online. MathematicalPie
Joined: 19 Aug 2014
Total Posts: 28
07 Jul 2016 04:51 AM
I'm not saying that, he's already made it very convoluted and that's what I'm working around. His method is terrible, I'm just giving a solution that fits his criteria, although yours works.
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
07 Jul 2016 04:53 AM
Oh, I wasn't saying yours was not necessary. I was on about OP's. Sorry for the confusion.


-=[ RAP: 347,257 || DurstAuric; the narb of ROBLOX ]=-
Report Abuse
MathematicalPie is not online. MathematicalPie
Joined: 19 Aug 2014
Total Posts: 28
07 Jul 2016 04:55 AM
Oh that's fine! I apologise too!
Report Abuse
DurstAuric is not online. DurstAuric
Joined: 12 May 2009
Total Posts: 8066
07 Jul 2016 04:56 AM
For something his style:

math.randomseed(tick() * math.random())
for Iteration = 1, 3 do
repeat wait()
LPN1 = math.random(1, 5)
until LPN1 == 3
-- Do stuff or break
end


-=[ RAP: 347,257 || DurstAuric; the narb of ROBLOX ]=-
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
07 Jul 2016 07:19 AM
math.randomseed(tick()%1*1e16)


c:
Report Abuse
mudkip99 is not online. mudkip99
Joined: 17 Jun 2008
Total Posts: 3362
07 Jul 2016 07:23 AM
Multiplying tick() or os.time() by math.random() doesn't really do anything. The random number generator will not have been seeded when the first math.random() is called, so you will get the same number out of it every time the game runs.

math.randomseed(tick()) or math.randomseed(os.time()) is enough in almost every situatuon, and modifying the seed any further than that really accomplishes nothing. The only way you'll get more random results is by making your own random number generator, which for most games on Roblox isn't really necessary.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
07 Jul 2016 07:36 AM
"Multiplying tick() or os.time() by math.random() doesn't really do anything. The random number generator will not have been seeded when the first math.random() is called, so you will get the same number out of it every time the game runs."

Not true. Roblox already seeds it, so it WILL be seeded before you seed it further. It's unnecessary most of the time when Roblox already does it though.

"math.randomseed(tick()) or math.randomseed(os.time()) is enough in almost every situatuon, and modifying the seed any further than that really accomplishes nothing."
Neither does setting the seed the first time, you know. As I said before, Roblox already seeds it.
And modifying it further DOES help with small ranges such as math.random(1, 10).


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