Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

if statement not realising a variable is something?

Asked by 4 years ago

OKAY, what is this? my variable is "-" and I have this:

local var = "-"
    print(var)
--output, -
        if not var == "-" then
            warn("hang on a minute...")
            ryt = ryt - 1

        end

and when it is "-", it does not do "hang on a minute"! can somebody help pleash?

0
use var != to instead of not == audyappy 1 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Because you did "not var", what it does is it equates "var" as being true since it exists, so the not statement made it the opposite of true which is false, and false is not equal to "-" so it didn't work. If you get rid of the "not" in front of the var, it should check to see if the string var is equal to "-" and if it is then it will execute the code.

local var = "-"
    print(var)
--output, -
        if var == "-" then
            warn("hang on a minute...")
            ryt = ryt - 1

        end
Ad

Answer this question