|
| 23 Jan 2012 05:57 PM |
| What would i do to choose a random model from a model in lighting? |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Jan 2012 06:00 PM |
| yes, i know i need math.random, but how would i sue that to find a random model from a model in lighting? |
|
|
| Report Abuse |
|
|
MXrcr20
|
  |
| Joined: 01 Oct 2008 |
| Total Posts: 2644 |
|
|
| 23 Jan 2012 06:01 PM |
models = game.Lighting:GetChildren() i = math.random(1,10)
if i == 1 then game.Lighting.Model1:clone().Parent = workspace end
if i == 2 then game.Lighting.Model1:clone().Parent = workspace end
etc... |
|
|
| Report Abuse |
|
|
MXrcr20
|
  |
| Joined: 01 Oct 2008 |
| Total Posts: 2644 |
|
|
| 23 Jan 2012 06:01 PM |
"models = game.Lighting:GetChildren()" Whoops. Forgot to take that out. I was going to do something else... |
|
|
| Report Abuse |
|
|
Cyrok
|
  |
| Joined: 11 Jan 2012 |
| Total Posts: 630 |
|
|
| 23 Jan 2012 06:03 PM |
math.randomseed(tick())
function returnModel() local modelTable = {} local lightingChildren = game:GetService("Lighting"):GetChildren() for index, value in pairs(lightingChildren) do if value:IsA("Model") then table.insert(modelTable, value) end end local randomModel = math.random(1, #modelTable) return randomModel end
local modelObject = returnModel()
{ I have an OCD when it comes to non-camelCase variables/custom functions. } |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 06:05 PM |
| thats what i was going to do before, but im need it to choos one thin g randomly and then anoither thin randomly. Which is why i wanted to know how to choose a random model from lighting. If i dont do this, my script will be very inefficent. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 06:09 PM |
| My last post was a responce to MXrcr20. |
|
|
| Report Abuse |
|
|
xvgigakid
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 4407 |
|
|
| 23 Jan 2012 06:12 PM |
@Unholy
Here is a really simple way to do this.
lighting = game.Lighting:GetChildren() num = math.random(1, #lighting) object = lighting[num]:clone() --Random Model Has Been Cloned. |
|
|
| Report Abuse |
|
|
|
| 23 Jan 2012 06:13 PM |
@Xv But what if has other things in Lighting?
† KMXD † |
|
|
| Report Abuse |
|
|
| |
|
xvgigakid
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 4407 |
|
|
| 23 Jan 2012 06:36 PM |
@Knightmare
Well he could place all of the models that he wants to be randomly selected in a DIFFRENT Instance. Then place that Instance inside lighting. Then do
I = Instance:GetChildren() --Blah Blah.
|
|
|
| Report Abuse |
|
|