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 5 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?

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

1 answer

Log in to vote
1
Answered by
F_F 53
5 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

local Strings = 

{

    ["WindowParts"] = true

}

local tab = {}
local descendants = workspace:GetDescendants() -- Location of where you have "WindowParts"


for _,index in pairs(descendants) do
    if Strings[index.Name] then
        table.insert(tab, index)
        print(index)
    end
end
Ad

Answer this question