I’m trying to figure out how to use :GetDescendants() to return an array with all objects with certain name’s paths, such as: If the parts are named “TestPart” then it returns with all paths of all bricks named “TestPart”
local testtable = {}
local testdescendants = workspace:GetDescendants()
for i,v in pairs(testdescendants) do
-- I'm stuck at this part
end
local testtable = {}
local testdescendants = workspace:GetDescendants()
for i,v in pairs(testdescendants) do
if v.Name == "TestPart" then
print(v.Name.." Found")
end
end
Can’t you just call :GetFullName on every part that is named “TestName” by using an conditional check?
local testtable = {}
local testdescendants = workspace:GetDescendants()
local testnameinstancepaths = {}
for i,v in pairs(testdescendants) do
if v.Name == "TestPart" then
table.insert(testnameinstancepaths, v:GetFullName())
--Alternatively, you could just do what you want to with them here, instead of storing them in a table to do something else with it later.
end
end
--Do what you want to do with testnameinstancepaths table here.