Okay first, don't tell me to go use string.find because that is not what I am to use, string.find only finds patterns/characters, not words. string.gmatch should work just fine.
Now, I am making script for ice cream. First it checks if the string specifies one scoop, if it specifies two scoops then it goes to two scoops in there. From then on for each one and two scoops it tries to check if the string had the flavor vanilla, or chocolate, or mint. However, even if the string contains chocolate and no vanilla it is still changing the value to the value if it found vanilla.
local menuChoices = {"one scoop of vanilla please", "I want one one scoop of chocolate",
"gimmie two scoops of vanilla"
}
local IceCreamChoice = script.Parent.StringValue
local chosenMenuChoice = menuChoices[math.random(1, #menuChoices)]
brick.Name = chosenMenuChoice
if string.gmatch(chosenMenuChoice, "one" ) then
if string.gmatch(chosenMenuChoice, "vanilla") then
iceCreamChoice.Value = "osv"
elseif string.gmatch(chosenMenuChoice, "chocolate") then
iceCreamChoice.Value = "osc"
elseif string.gmatch(chosenMenuChoice, "mint") then
iceCreamChoice.Value = "osm"
end
elseif string.gmatch("two", chosenMenuChoice) then
if string.gmatch(chosenMenuChoice, "vanilla") then
iceCreamChoice.Value = "tsv"
elseif string.gmatch(chosenMenuChoice, "chocolate") then
iceCreamChoice.Value = "tsc"
elseif string.gmatch(chosenMenuChoice, "mint") then
iceCreamChoice.Value = "tsm"
end
end

9 comments
Your reason not to use string.find doesn't make any sense. string.find looks for characters and patterns in a string just like string.gmatch would. Same goes for string.match, string.gsub, etc.
@ScriptGuider Okay, fine, but using string.find does not solve my issue as I have tried it.....do you have any ideas? Just pretend I changed it all to string.find as I will be doing, it still does not solve my issue sadly.
@ScriptGuider when I try doing string.find instead of string.gmatch nothing works...at all. I have tried string.gmatch(chosenMenuChoice, "one" and string.gmatch("one" , chosenMenuChoice) doesn't change the value, I even put a print under that line and still nothing.
Sorry meant string.find not string/gmatch
You're only using pattern matching functions to find out if a sequence of characters exists, so it doesn't matter which function you use, whether it's find, match, gmatch, etc. Your problem would be with something else.
Please do not re-post the same question twice, unless if it's really necessary; you've already gotten answers on your past question, which explains what you can use & how you use them.
@ScriptGuider I don't fully understand. Does this mean I can't do what I am trying to do with string.find ? The string.find command looks for patterns, yes? In the wiki I see it being able to find bla in blahblah , shouldn't it be able to find "one" in my string?
@TheAlphaStigma Similar question but my code is different and I have had 0 replies within 3 hours but as you can see I have gotten many replies here. The only "answer" I can think of is to use string.find which does not work for me, it does not even show any print statements. idk what to do.
Yes, if it exists. Like Pyrondon said, which I didn't think of, gmatch is going to return a function regardless of whether or not a pattern was found, and you're only checking if what it returns exists, which it will in every case.