|
| 30 Dec 2016 06:16 AM |
For example:
model1 = workspace.model1:GetChildren() model2 = workspace.model2:GetChildren()
Now how would use both of these in a for loop?
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:17 AM |
for _,part in next,model1 do print(part.Name,"is a child of",part.Parent.Name) end
for _,part in next,model2 do print(part.Name,"is a child of",part.Parent.Name) end
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 06:18 AM |
| #### Won't work since i use waits in the loops and they have to be ran at the same time |
|
|
| Report Abuse |
|
|
| |
|
iYoshiFox
|
  |
| Joined: 14 Apr 2012 |
| Total Posts: 1058 |
|
|
| 30 Dec 2016 06:24 AM |
spawn(function() for _, v in pairs(model1) do -- Do stuff end end)
for _, v in pairs(model2) do -- Do Stuff end
They'll be ran at the same time. |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:24 AM |
function AffectModels(model1,model2) for _,v in next,model1 do print(v) end for _,v in next,model2 do print(v) end wait() -- wait can go here end
AffectModels( workspace.model1:GetChildren(), workspace.model2:GetChildren() )
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:24 AM |
You can use coroutines or spawning but I don't think you need to for your situation.
|
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Dec 2016 06:43 AM |
function AffectModels(model1,model2) for _,v in next,model1 do print(v) end for _,v in next,model2 do print(v) end wait() -- wait can go here end
AffectModels( workspace.model1:GetChildren(), workspace.model2:GetChildren() )
---------- this does not effect both tables at the same time still.. you really do need a co-routine or a single loop effecting both tables.
such would look like,
model1 = workspace.model1:GetChildren() model2 = workspace.model2:GetChildren()
n = #model1 m = #model2 time = --set time
if n >= m then for i = 0, m-1 do model1[i] = --make change model2[i] = --make change wait(time) end for i = m to n-1 do model1[i] = --make change end else for i = 0, n-1 do model1[i] = --make change model2[i] = --make change wait(time) end for i = n to m-1 do model2[i] = --make change end end
.//. but you should probably just use a co-routine. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 06:44 AM |
| this is much simpler if the tables are a fixed length and the same length, but just in case it isnt ^^ that should work |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 06:48 AM |
Prestigious, you missed the point of my approach, which was to make incremental assortments to the two tables.
If he's simply affecting the CFrame of each part in each model, both models are being affected in the same frame and then given a wait(), so you might as well not even piss with coroutines.
function Fly(model1,model2) for _,v in next,model1 do v.CFrame = v.CFrame*CFrame.new(0,.1,0) end for _,v in next,model2 do v.CFrame = v.CFrame*CFrame.new(0,.1,0) end wait() -- each step will look like both are flying at the same time, because, well, they basically are. end Fly(workspace.model1:GetChildren(),workspace.model2:GetChildren())
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 06:58 AM |
and you are calling the fly function in a loop right?
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 07:00 AM |
| ah ok i see now, we are moving models, i thought he wanted the wait time in between each child of the model, my bad |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 30 Dec 2016 07:01 AM |
*Ya to your first post As for your second, I don't know. ¯\_(ツ)_/¯ OP didn't go that specific. I just assumed if you're getting the children of a model and putting them in a loop that you're moving them.
|
|
|
| Report Abuse |
|
|
| |
|