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
 

I can't seem to get a random number out of 100.

Previous Thread :: Next Thread 
loterman23 is online. loterman23
Joined: 06 Apr 2008
Total Posts: 178
08 Mar 2017 03:10 AM
I've used math.random countless times before but for whatever reason, it wont work even if I only have print(math.random(1, 100)) in a script alone, in an empty workspace, but it keeps printing 89.
Report Abuse
CoreyWasNukedX2 is not online. CoreyWasNukedX2
Joined: 25 Jun 2014
Total Posts: 150
08 Mar 2017 03:16 AM
If you are using Roblox Studio to run the script, the outcome never changes. Weird, right?
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
08 Mar 2017 03:18 AM
You can't just declare it once

saying number = math.random(1,100)

print(number)
wait(1)
print(number)

will print

> 89
> 89

You need to spice it up. Make a function instead

math.randomseed(tick())
function GenerateRandomNumber(min,max)
return math.random(min,max)
end

while wait(math.random()) do
print(GenerateRandomNumber(1,100))
end






Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
08 Mar 2017 06:32 AM
You need to use math.randomseed to have a random seed to generate, otherwise it will always use the same seed and never have a different outcome.
Report Abuse
Customality is not online. Customality
Joined: 11 Aug 2015
Total Posts: 590
08 Mar 2017 08:57 AM
math.randomseed(tick())
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