Hello guys, I’m working on a function that can find me specified objects inside an object, then return a table contains it.
I’ll go straight into the problem : The tables won’t merge up together.
I think the issue is on the code problem but I can’t find it out. It would be nice if you can spend sometime on this simple problem. Thank you!
— Find instances —
local function GetObjects(address,objname)
local Table = {}
for _,v in pairs(address:GetChildren()) do
if v.Name == objname then
table.insert(Table,v)
print(Table)
end
if v:GetChildren() ~= nil then
local subTable = GetObjects(v,objname)
mergeTables(Table,subTable)
end
end
return Table
end
— Merge Tables function —
local function mergeTables (tab1, tab2)
for _,v in pairs(tab1) do
table.insert(tab2,v)
end
return tab2
end