Greetings there, so I had a question with a table that I’m making. I’m trying to see if there is any way I can collect some values inside a table, for example:
"SGM1", "SGM2", "SGM3", "SGM4", "SGM5", "SGM6", "SGM7", "SGM8", "SGM9", "SGM10"
}
local descendants = game.Workspace.Test
for _, v in pairs(descendants:GetChildren()) do
if table.find(MyTable, v.Name) then
v.Transparency = 1
print("found!")
else
print("didnt found!")
end
end
Let’s say I want to collect only the “SGM1”, “SGM2” Inside my table, how can I do that?
So as you can see we have a Table, inside it stores some objects names. “SGM1”, “SGM2” , “SGM3”, “SGM4” etc, now for example let’s say I want to only get the “SGM5”, “SGM7” name. How can I do that? Is it possible?
Replying to the top answer, I don’t wanna do that because my script is going to be a mess and I don’t want to have bunch of tables everywhere.
Please if you don’t know the question don’t fill the devforum with bunch of random answers, I can’t explain it more, I’ll just wait for another person to reply! Thank you.
Do you mean this? Though this doesn’t make any sense since you already created a table with the strings in it.
local toSearch = {
"SGM1", "SGM2", "SGM3", "SGM4", "SGM5", "SGM6", "SGM7", "SGM8", "SGM9", "SGM10"
}
local toFind = { "SGM1", "SGM2" }
local result = {}
for _, item in toSearch do
if table.find(toFind, item) then
table.insert(result, item)
end
end
This doesn’t make any sense because toFind is already what result is going to become after running the script.