|
| 13 Aug 2015 01:17 AM |
So basically there is a folder in ServerStorage named Investiage, which has models in it.
These models are just one charcter with different arm positions etc They are named like this
F1 F2 F3 F4
and so on,
I want to loop through the children of Investiage get the F1 model put it workspace, destroy it, get the next model which is F2 put it in workspace and so on.
I'm trying to figure out the most efficient way to do this isntead of having a 100 line script of trash.
Can anyone help? |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2015 01:22 AM |
for i, v in pairs(game.ServerStorage:GetChildren()) if v:IsA("Model") then if v.Name:sub(1, 1) == "F" then
end end
I so far have this, but I want to add them in according to their number
F1 F2 F3 F4
I don't just want to add them all in.
So in this loop I want to
Get the next F in according to the number after the F
add the first F in wait() destroy the first f add in the next F wait() destroy that f
and so on.
As I have said I'm trying to make it efficient. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 13 Aug 2015 07:31 AM |
for i,v in next,game["ServerStorage"]["Investigage"]:GetChildren() do if game["ServerStorage"]["Investigage"]:FindFirstChild("F"..i) then v:Clone().Parent = workspace end end |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2015 07:32 AM |
I don't think that will
Add F2 in wait() Destroy Add F2 in wait() Destroy
and so on. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2015 07:33 AM |
for i,v in next,game["ServerStorage"]["Investigage"]:GetChildren() do if game["ServerStorage"]["Investigage"]:FindFirstChild("F"..i) then v:Clone().Parent = workspace wait(1) end end
This will work. I tested it. |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2015 07:33 AM |
| I do see it adding them all in however based on the current index. but how fast does it iterate through a table. |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Aug 2015 07:36 AM |
oh. If you are going for speed, do this.
for i = 1,#game["ServerStorage"]["Investigage"]:GetChildren() do if game["ServerStorage"]["Investigage"]:FindFirstChild("F"..i) then game["ServerStorage"]["Investigage"]["F"..i]:Clone().Parent = workspace end end |
|
|
| Report Abuse |
|
|
|
| 13 Aug 2015 08:45 AM |
If you would like Speed and efficiency:
local Investigage = game:GetService("ServerStorage"):WaitForChild("Investigage") for i = 1,#Investigage:GetChildren() do local F = Investigage:FindFirstChild("F"..i) if F then F:Clone().Parent = workspace end end |
|
|
| Report Abuse |
|
|