ardrous
(ardrous)
#1
I am trying to make an if statement with 3 conditions.
Instead of using this,
if randomString == "Hello" or "Good" then
if randomString == "Bad" then
print("OK")
end
end
I would like to make it something like,
if randomString == "Hello" or "Good" or "Bad" then
print("OK")
end
I am aware that the script above will not work.
1 Like
Valkyrop
(JustAGuy)
#2
Your 2nd script won’t work. It’d print ‘OK’ for every string you’ll put as ‘randomString’.
Try this
if randomString == "Hello" or randomString == "Good" or randomString =="Bad" then
print("OK")
end
ardrous
(ardrous)
#3
I was struggling with this issue for a long time.
Thank you so much! 
1 Like
Valkyrop
(JustAGuy)
#4
Another way you could do, is
local myWords = {"Hello","Good","Bad"}
for index,word in pairs(myWords) do
if randomString == word then
print("OK")
end
end
In here, you’re looping through yourWords table, and check if ‘randomString’'s value can be found there. If it is, then print ‘OK’
Forummer
(Forummer)
#5
if table.find(myWords, randomString) then
Valkyrop
(JustAGuy)
#6
Correct, that’s the brief way to do that