|
| 06 May 2014 10:52 PM |
I want to make a loot system I need math.random to pick a random position that I made for the items to spawn and I don't know if this works or not.
My code: math.random(489, 576, 589/475, 583, 563/473, 473, 584) |
|
|
| Report Abuse |
|
|
Vuva
|
  |
| Joined: 22 Jan 2010 |
| Total Posts: 1102 |
|
|
| 06 May 2014 11:12 PM |
with math.random, you can only have two parameters for the minimum and maximum random value. It would be better to put the numbers into a table, and then access a random element in the table. And also, positions should be manipulated with Vector3 values.
SomeTable={Vector3.new(489, 576, 589),Vector3.new(475, 583, 563),Vector3.new(473, 473, 584)} RandomPosition=SomeTable[math.random(1,3)] |
|
|
| Report Abuse |
|
|
|
| 06 May 2014 11:45 PM |
| Is randomposition a real method? Yesterday I learned about the method to move models called MoveTo and it was a real method. |
|
|
| Report Abuse |
|
|
|
| 06 May 2014 11:54 PM |
It can be a real method if you want it to be :D (You have to define it and all.)
So you can't just create a news script and put blah:randomposition(somevector). |
|
|
| Report Abuse |
|
|
|
| 06 May 2014 11:56 PM |
Aparently RandomPosition isn't a real method heres what I made:
SomeTable = {Vector3.new(489, 576, 589),Vector3.new(475, 583, 563),Vector3.new(473, 473, 584)} workspace.Part.Position = SomeTable[math.random(1,3)]
I'm actually good at scripting I just don't know some things. Thanks for the help. |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 02:16 AM |
"Aparently RandomPosition isn't a real method" No, ScrewDeath is right. You just have to believe! (and write a bunch of code) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 07 May 2014 02:24 AM |
function Random(...) local Temp = {...} return Temp[math.random(1, #Temp)] end
hi = Random(Vector3.new(0, 0, 0), Vector3.new(1, 1, 1), Vector3.new(2, 2, 2), Vector3.new(3, 3, 3)) |
|
|
| Report Abuse |
|
|
|
| 07 May 2014 02:25 AM |
Use select for tuples! :P
local function Random(...) return (select(math.random(select("#",...)),...)) end |
|
|
| Report Abuse |
|
|