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: Math.Random with numbers???

Previous Thread :: Next Thread 
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:27 PM
i know how to use math.Random with strings in a table but how can you make it so that it chooses a certain number within a certain range. i need this for an RPG project im working on.

please help me
Report Abuse
Frostglacier is not online. Frostglacier
Joined: 28 Oct 2010
Total Posts: 4177
23 May 2013 06:28 PM
a = math.random(1,1337)
if a == 1337 then
print 'that was cool'
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:37 PM
thanks! so say i wanted a number to be multiplied by a certain percent i would do

x = math.random(0.5, 1)
b = DmgAverage*x

???
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
23 May 2013 06:40 PM
yes
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:41 PM
its not working the damage comes up either as 200 or zero. does the 0.5 count as a zero? and why does it not do any decimals in between?
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:43 PM
In math.random the smaller number has to go first.
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:44 PM
oops didnt realise you were.
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:45 PM
so then what is wrong???
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:45 PM
while wait(0.1) do
print(math.random(0.5, 1)
end

post output
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:49 PM
the output says
0
1
0
1
1
1
0
0
1
0
1
0
1
1
0
0
0
0
1
etc.
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
23 May 2013 06:51 PM
thats why.

do you know math?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
23 May 2013 06:52 PM
math.random does not accept decimal values. Floats, if you like.

while wait(0.1) do
print(math.random(5, 10)/10)
end
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:57 PM
Pokemon yes i know math. im in 7th grade and in advanced math i should know it by now.
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 06:58 PM
good idea MrNicNac it worked. i wish i had thought of doing that.
Report Abuse
vulture97 is not online. vulture97
Joined: 09 Feb 2009
Total Posts: 1589
23 May 2013 07:03 PM
Use math.random(5,10) instead of math.random(0.5,1), and divide it by ten.

Example:

x = math.random(5,10)
print (x/10)

The output should then read between .5 and 1.
Report Abuse
tastefulbobo is not online. tastefulbobo
Joined: 14 May 2010
Total Posts: 166
23 May 2013 07:08 PM
thank you but someone above took care of it already.
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