I doubt it would be very optimal to add all of their children to one table, so you might consider putting just the containers in a table. This reduces the syntax to two loops no matter how many containers you want to iterate through.
local containers = {workspace, game:GetService("ServerScriptService")}
for _, container in ipairs(containers) do
for _, child in ipairs(container:GetChildren()) do
...
end
end
Thought of this, but in my for-loop when iIcall the function :GetFullName() I get the error āattempt to call missing method āGetFullNameā of tableā.
for i, v in pairs(game.ServerScriptService()) do
textBox.Text = v:GetFullName()
end
for i, v in pairs(game.Workspace:GetDesentants()) do
textBox.Text = GetFullName()
end
I want to merge them because I have some other code that requires them to be together.
You arenāt calling a method of ServerScriptService in the first loop. The method in the second loop should be GetDescendants(), and GetFullName() isnāt being called by an object.
table.move() provides a convenient way to combine tables.
local childrenA = workspace:GetChildren()
local childrenB = game:GetService("ServerScriptService"):GetChildren()
-- Add childrenB to the end of childrenA
table.move(childrenB, 1, #childrenB, #childrenA + 1, childrenA)
for _, child in ipairs(childrenA) do
print(child)
end