local mathchoice = math.random(0, 1) local choices = string.sub(message.content, 8) local choice0 = string.sub(choices, string.len(string.sub(choices, string.find(choices, " or ")-2))) local choice1 = string.sub(choices, string.len(choice0)) if mathchoice == 0 then choice = choice0 elseif mathchoice == 1 then choice = choice1 end print(mathchoice) print(choice)
I'm trying to find choice0 then find choice1. The best idea I've had is to find everything up to " or" and remove " or" and everything after it. Once that's done it could be used to find choice1. Any idea on how to make that happen?
local c = math.random(0, 1) local message = "corndogs or hotdogs" local conj = message:find(" or ") local choice = c == 1 and message:sub(1, conj-1) or message:sub(conj+4) print(choice)