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: How to make math.random actually random?

Previous Thread :: Next Thread 
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 03:41 PM
math.randomseed(tick()) doesn't work the slightest, tried it countless times.
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
27 Apr 2014 03:52 PM
you're not using math.randomseed() right then.

#nerdsunited
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 04:45 PM
There's 10 maps. It always only chooses two. The script makes it unable to choose the same map twice, so it just repeats between the two.

math.randomseed(tick())
wait()
choose = true
mapDirectory = game.ServerStorage.MAPS
maps = mapDirectory:getChildren()
while choose == true do
pickedMap = maps[math.random(1, #maps)]
wait()
if pickedMap.ID.Value == game.Workspace.LastMap.Value then
print("Choosing another map..")
wait()
else
print("Map chosen!")
choose = false
end
end
game.Workspace.LastMap.Value = pickedMap.ID.Value
local pickedMapClone = pickedMap:clone()
pickedMapClone.Parent = game.Workspace
pickedMapClone:makeJoints()
script.Parent.ready.Value = true
script.Disabled = true
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 04:54 PM
Bump.
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 05:17 PM
Bump.
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 06:01 PM
Bump.
Report Abuse
Demystified is not online. Demystified
Joined: 05 Nov 2007
Total Posts: 6580
27 Apr 2014 06:02 PM
Well it will never be TRULY random.
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 06:26 PM
math.randomseed(tick()) is meant to at least break any patterns.
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
27 Apr 2014 06:34 PM
and it does.

#nerdsunited
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 06:45 PM
It doesn't in my case.
Go to my game, Stop it Slender, and try to tell me the map rotation doesn't constantly repeat the same 2-3 maps.
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
27 Apr 2014 06:46 PM
httpservice
random(DOT)org
json fun

i'm asian
Report Abuse
Demystified is not online. Demystified
Joined: 05 Nov 2007
Total Posts: 6580
27 Apr 2014 06:47 PM
@jigg

Never thought of that. Should make that a project.
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
27 Apr 2014 06:48 PM
because math.random() is a PRNG (mersenne twister probably) and randomDOTorg is a TRNG from thermal noise or something

i'm asian
Report Abuse
L0cky2013 is not online. L0cky2013
Joined: 30 Jul 2012
Total Posts: 1446
27 Apr 2014 06:52 PM
Do you literally expect it to be different every time? If you do then it isn't random... obviously the more things you have to choose form, it will choose things more randomly
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 06:59 PM
@L0ck;
I don't even know what you're talking about..

@Jigg;
I've heard of this before, but I'm confused how to use it.
Report Abuse
L0cky2013 is not online. L0cky2013
Joined: 30 Jul 2012
Total Posts: 1446
27 Apr 2014 07:00 PM
It wouldn't be random if you want it to be different every time
Report Abuse
L0cky2013 is not online. L0cky2013
Joined: 30 Jul 2012
Total Posts: 1446
27 Apr 2014 07:01 PM
@kinnis,

api.random.
org/
json-rpc/
1/
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 07:09 PM
I'm not sure if you're trying to avoid the link filter or what?...
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 09:50 PM
Bump.
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
27 Apr 2014 10:47 PM
Bump.
Report Abuse
JigglingJack is not online. JigglingJack
Joined: 25 Mar 2014
Total Posts: 11263
27 Apr 2014 11:04 PM
use httpservice RANDOM(DOT)ORG

i'm asian
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
28 Apr 2014 02:18 AM
I've never used httpservice or know where to put "RANDOM(DOT)ORG".
Report Abuse
Kinnis97 is not online. Kinnis97
Joined: 21 Feb 2010
Total Posts: 1683
28 Apr 2014 02:46 PM
Guys I'm trying to get math.randomseed(tick()) to work properly, not find other methods of random numbers.
Report Abuse
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
28 Apr 2014 02:57 PM
It would be a problem with the seed if it chose the same maps in the same order every time (eg. 3, 5, 2, 8, 5, 8, restart, play again, 3, 5, 2, 8, 5, 8, rinse and repeat).

If it's a problem with picking the same two maps repeatedly... then the problem is that it "thinks" there's only two maps.

I can't be sure what the exact problem is, it's been a long time since I've actually scripted, but I hope I help at least a little.
Report Abuse
samy22 is not online. samy22
Joined: 28 Sep 2008
Total Posts: 2181
28 Apr 2014 03:12 PM
--This is as random as i can make it with reference to the wiki on random numbers, try this?


math.randomseed(tick())
wait()
choose = true
mapDirectory = game.ServerStorage.MAPS
maps = mapDirectory:getChildren()
while choose == true do
pickedMap = maps[math.random()*#maps] --This is the change I've made.
wait()
if pickedMap.ID.Value == game.Workspace.LastMap.Value then
print("Choosing another map..")
wait()
else
print("Map chosen!")
choose = false
end
end
game.Workspace.LastMap.Value = pickedMap.ID.Value
local pickedMapClone = pickedMap:clone()
pickedMapClone.Parent = game.Workspace
pickedMapClone:makeJoints()
script.Parent.ready.Value = true
script.Disabled = true
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