#Why is this condition not running?

1 messages · Page 1 of 1 (latest)

olive mantle
#
if not string.find(hit.Name,"cactus") or not string.find(hit.Name,"MagmaObbyPart") or not string.find(hit.Name,"Crystal") or not string.find(hit.Parent.Name,"Tree") then return end
print("this ran")

this will only run if the hits name is not at least one of these correct? do I need this many nots? I only want it to return end if none all of these are not met. Why does it not print when the hits name is literally has MagmaObbyPart?

rancid cosmos
#

why are you using string.find? are you trying to check the name?
to check a string you can simply do hit.Name == “whatever”

#

not at my pc right now but with string.find(“blablablablablaCrystal”, “Crystal”) would still return smth that makes it true

strong sapphire
olive mantle
olive mantle
#

oh

#

will it only move to the next one if the previous one is not true?

rancid cosmos
#

because of the or operation

#

the fix is removing the nots

olive mantle
thick archBOT
#

studio** You are now Level 11! **studio

olive mantle
#

I am literally stating if not cactus or not magmaobby part etc so I am stating if its not this then check if its the next one and if its not then move to the next or, if its false then it won't return end

#

it will only return end if none are not met yes?

#

if none of them are in the string

#

but if one is then it will not return end

#

right?

rancid cosmos
#

its because thats not how it works, the if statement will execute if at least one of those is true

thick archBOT
#

studio** You are now Level 4! **studio

rancid cosmos
#

because thats how the OR operation works

olive mantle
strong sapphire
#

if not a or b or c or d then is not the same as if not (a or b or c or d) then

olive mantle
strong sapphire
#

the not keyword usually comes before things, not after?

olive mantle
strong sapphire
#

i think you misunderstand how conditions work

#

or means either can be true. and means both must be true. not a and b means a must be false and b must be true.

#

not a or b means either a is false, or b is true.

#

very simple. Elementary even.