Not working comparing numbers

i have a script that has

if tonumber(guess.Letter1.Text) == tonumber(splitanswer[2]) or tonumber(splitanswer[3]) or tonumber(splitanswer[4]) or tonumber(splitanswer[5]) then
      --script--
end

just say i do

print(tonumber(guess.Letter1.Text), tonumber(splitanswer[2])..tonumber(splitanswer[3]).. tonumber(splitanswer[4])..tonumber(splitanswer[5]))

itll print something like 5 6782 and 5 is not equal to 6 or 7 or 8 or 2, but the script still runs whatever is in the if statement

it’s because the logic statement is messed up

if 1 + 1 == 1 or 3 then
end

this doesn’t equate to “if 1+1 is 1 or 1+1 is 3”, it just checks if 1+1 == 1, if it’s not, it checks
if 3 then
well, 3 isn’t nil, so the statement is true

here’s a solution that may work for your case

if table.find(splitanswer, guess.Letter1.Text) then
	--script--
end

you shouldn’t be repeating statements if you don’t have to; I worship table.find

would it wokr because splitanswer isnt a table

if it’s not a table, then what is it?

nvm it works thank you very much!!

awesome, glad to know it works for you

not to bug you but also how could I check what index it is checking like if you have 12345 and the table.find will check if guess.letter1.text == 1 then itll check if it is equal to 2 and so on i think

how could i check like if its checking to see if splitanswer[2] or whatever is equal to guess.letter1.Text

and then do if table.find says that splitanswer[3] is equal to guess.Letter1.Text i could check if splitanswer[3] has a background color of like 67,89,234 or something

are you talking about finding the index in splitanswer? because table.find returns the index iirc
print(table.find(tablehere, object))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.