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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 24 Jan 2010 |
| Total Posts: 172 |
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 24 Jan 2010 |
| Total Posts: 172 |
|
| |
|