Take a look at the for loop and the word part of it specifically.
local words = {
"One - Test",
"Two - Test",
"Three - Test"
}
local find = "Test"
local function getWord(partialName)
partialName = partialName:lower()
for _,word in ipairs(words) do
if string.find(word:lower(),partialName) then
print(word)
end
end
end
getWord(find)
Output:
One - Test
Two - Test
Three - Test
I'm trying to store everything that gets outputted to other variables. print(word) outputs what you see above, but how can I only get the One - Test result of it and store it to another variable? I've tried using print(word[1]) to test it out, but it didn't work and outputted nil.
nil (x3) - Client - Local Script:14
Now how can I fix that? Very much appreciated!
One, orOne - Test? IfOne, you need to split the string and return the first part, ifOne - Test, you can get it bywords[1].huge_table = { ["One - Test"]=true, ["Two - Test"]=true }, then searching for some key would be justhuge_table["One - Test"].One - Testis not a word. You should use more suitable names. Same forgetWord. A function named getWord should return a single word.