Issue with "and" statement with numbers

If val is either Honda or Jeep or BMW and v is 2 I want it to print cars issue I am having is when val is Honda or Jeep or BMW and v is 1 it still prints cars

if val.Value == "Honda" or val.Value == "Jeep" or val.Value == "Bmw" and v.Value == 2  then
print("CARS")
3 Likes

Try this:

if (val.Value == "Honda" or val.Value == "Jeep" or val.Value == "Bmw") and v.Value == 2  then
print("CARS")
1 Like

Now when I do it and if v is 2 and val is Jeep it won’t print

Atleast fix some of your grammar with grammarly so people can understand easily.

So the logic you want is that either val value is between Honda, Jeep, and BMW and the v value is must equal to two and after the requirements is approved it prints Cars, is that what you mean?

So if it is, here’s the new code

if val.Value == "Honda" or val.Value == "Jeep" or val.Value == "BMW" then
    if v.Value = 2 then 
        print("Cars")
    else end
end

--[[
hi :3
]]

Mark as solution if it was right. Thank you

1 Like
if (val.Value == "Honda" or val.Value == "Jeep" or val.Value == "Bmw") and v.Value == 2  then
    print("CARS")
end
1 Like

Try rearranging the order see if that works

if (v.Value == 2) and (val.Value == "Honda" or val.Value == "Jeep" or val.Value == "Bmw") then   
1 Like

This seemed to have fixed the problem! Thank you!

1 Like

This didn’t work sadly if the val is Jeep and v is 2 it still won’t print cars

This would work, but I am trying not to use so many if statements in my script

You should’ve said it in the question, but okay

sorry about that, I must have forgot

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