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

why doesnt my " IF a==true AND b== true THEN" not work?

Asked by 2 years ago

I have 2 variables and i want code to run when both of them are true. But for some reason even when both of them are true the code doesnt run, i have tried putting different code inside the statement but none of it will run. I have tried "while a==true do print(a)" and it says its true, sane with the other variable, but for some reason the code will not run, please help

1 answer

Log in to vote
0
Answered by
is6ak 0
2 years ago
Edited 2 years ago

So you want a code to run/get triggered after a value is set to true? You can do this by making a loop, using setmetatable and making a boolvalue that you can :GetPropertyChangedSignal.

Assuming you're new to scripting, I'll just make a loop for you as it's the easiest, but not the best thing to use in terms of optimised code.

local Bool = false;

spawn(function()
    while wait() do
        if Bool == true then
            print("true");
            break; -- This will break the loop, making the loop run only once when the bool is set to true.
        end;
    end;
end);

wait(.3)
Bool = true;
Ad

Answer this question