Need Help With A Table!

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?

Can you explain more? I don’t understand! :sweat_smile:

Just contain SGM1 and SGM2 inside the table.

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.

why?ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ
why you want to get the random 2 values?

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.

Is the variable local descendants = game.Workspace.Test a Folder in workspace?

Yeap, it’s located in a folder!

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.