for _,child in pairs(workspace.Tycoon.Buttons:GetChildren()) do
local Search = {}
table.insert(Search, child.Name)
end
for _,child in pairs(workspace.Tycoon.Buttons:GetChildren()) do
child.config.Source:find()
end
(This isnt finished but im stuck, thats why im asking here)
How would I loop through the entire table here?
child.config.Source:find()
In example i want to search the script for every word in the table, how could I do this?
Is this what you want to do? I don’t entirely understand your problem.
local function findTable(...)
for _,child in pairs(workspace.Tycoon.Buttons:GetChildren()) do --loop through table
local result = child.config.Source:find(...) --use string.find normally
if result then
--return result
return child
end
end
end
print(findTable("blahblah"))
Wow, yes! That could work.
Just one more question: How could I only print the result if 2 scripts have the same result?
In example 1 script has “NameX” as a result, and Script2 has the same result. Then i want NameX to be printed.
Instead of it returning the first value it finds i think it is better if it returns a table of every valid result.
local function findTable(...)
local results = {}
for _,child in pairs(workspace.Tycoon.Buttons:GetChildren()) do --loop through table
local result = child.config.Source:find(...) --use string.find normally
if result then
--return result
table.insert(results, child)
end
end
return results
end
print(findTable("blahblah")) --now returns a table of everything that it could find
Now if there are two or more things with the same name it will return all of them inside a table, keep in mind that it will return an empty table if it doesn’t find anything.
I’m sorry but i don’t understand, the function above returns a table of every single match, if you don’t want a specific result you can simply remove it from the table.
Maybe you can tell us on a broader scope what you’re trying to achieve?
Wait, am i supposed to add child.Name here local result = child.config.Source:find(…)
Or are the three dots intentional, cuz i replaced them with child.Name so it should give me all the button names basically. But its just an empty table.
local function test(...)--no matter how many arguments i give, it will get all of them
print(...)
end
test("a", "ghhaa", "sdana") --> prints "a ghhaa sdana"
test("a", "ghhaa", "sdana", "evenmore", "arguments", "yes") --> prints "a ghhaa sdana evenmore arguments yes"
In this case i use so you can use all the arguments string.find has:
local function findTable(...)
local results = {}
for _,child in pairs(workspace.Tycoon.Buttons:GetChildren()) do
local result = child.config.Source:find(...) --give all the arguments passed
if result then
table.insert(results, child)
end
end
return results
end
... is the arguments you give, you can read the code and edit to what you desire, “blahblah” was just
a placeholder, you were supposed to change it to what you wanted to find, i do not know what you want to find.