Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I put multiple parts in a table that have the same name?

Asked by 6 years ago

I don't even know if the parameters for GetChildren() even do anything, but I thought to put the name of the parts I want indexed as a parameters which did nothing. How do I do this, if it's even possible without making individual variables for each part?

1local windows = script.Parent.Parent.Parts:GetChildren("WindowParts")

1 answer

Log in to vote
1
Answered by
F_F 53
6 years ago

What you could do is make a dictionary table with the name of the parts and look through a specific service to look for the specific part

01local Strings =
02 
03{
04 
05    ["WindowParts"] = true
06 
07}
08 
09local tab = {}
10local descendants = workspace:GetDescendants() -- Location of where you have "WindowParts"
11 
12 
13for _,index in pairs(descendants) do
14    if Strings[index.Name] then
15        table.insert(tab, index)
16        print(index)
17    end
18end
Ad

Answer this question