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 help.

Previous Thread :: Next Thread 
kurnalD is not online. kurnalD
Joined: 24 Jan 2010
Total Posts: 172
10 Nov 2012 11:56 AM
How can I use mat.random to select teams rrandomly. I dont get how to use math.random
Report Abuse
Taniss99 is not online. Taniss99
Joined: 15 Dec 2007
Total Posts: 1707
10 Nov 2012 12:16 PM
The random gives you a random int, you can then do a series of if statements that determine what map should be loaded for each int that it might give you
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
10 Nov 2012 12:18 PM
Whenever u don't get something, go here:

http://wiki.roblox.com/index.php/Function_Dump/Mathematical_Functions

Type math.random, or whatever. It will tell u everything.

All random does is give u a number between 0 and 1, the same as in any other language.

So, go

If Random is less than .5 then --- Heads or tails?
-- head code
else -- tail code
end -- Head or tails

Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
10 Nov 2012 12:21 PM
@bj

Not in roblox lua. Math random gives you a random integer, in between 0 and 1. You can specify the numbers, for example math.random(5,15) will give you a whole number in between 5 and 15. If you wanted to make it decimalized, you could do like
x = math.random(1,100)
realx = x/10

print(realx)

>1.3

you could edit it to your needs.
Report Abuse
BELLYBUTTONMAN5 is not online. BELLYBUTTONMAN5
Joined: 03 Jul 2010
Total Posts: 160
10 Nov 2012 12:40 PM
local num = math.random(1,4)
if num == 1 then
--code here
elseif num == 2 then
--code here
elseif num == 3 then
--code here
elseif num == 4 then
--code here
end
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
10 Nov 2012 01:29 PM
Sorry Awesome Dude,

I meant: The function math.random() returns a number between 1 and 0.
Report Abuse
kurnalD is not online. kurnalD
Joined: 24 Jan 2010
Total Posts: 172
10 Nov 2012 02:40 PM
But can any of you help me make a script that can give any player in my game a random number through 6
Report Abuse
kurnalD is not online. kurnalD
Joined: 24 Jan 2010
Total Posts: 172
10 Nov 2012 02:42 PM
OH ok nvm.
Report Abuse
kurnalD is not online. kurnalD
Joined: 24 Jan 2010
Total Posts: 172
10 Nov 2012 02:43 PM
Wait how do I get the script to give a random number to each player
Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
10 Nov 2012 03:13 PM
You don't.

Go to Catalog; search on whatever u want, like, Team Switxher, or Balance Team. You will find 50 scripts which say they do that whatever.

Test. Test. Test, 'til u find a good one. Then tweek the code slightly, to do what u want it to do.

GL,
Brian
Report Abuse
LUVMARIOLUIGI10000 is not online. LUVMARIOLUIGI10000
Joined: 16 May 2009
Total Posts: 1244
10 Nov 2012 03:39 PM
There is a function called RebalanceTeams() that rebalances the teams, but you ca use math.random() to do this as well. math.random() is not just for numbers.
Report Abuse
kurnalD is not online. kurnalD
Joined: 24 Jan 2010
Total Posts: 172
10 Nov 2012 04:50 PM
@ Bj that horrible tips. But I want to know how to assign each player a number
Report Abuse
kurnalD is not online. kurnalD
Joined: 24 Jan 2010
Total Posts: 172
10 Nov 2012 08:06 PM
bump
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