Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

(Solved) How do i check if multiple variables are true or not in an if-statement?

so basically i want to do a movement system for my tool. For it to work i need to check if the different Keys (W key, A key, S key, D key) are pressed. Im using an if statement for it but it wont work because you cant put multiple "ands" in an if statement. Heres the code that im stuck with:

if wPressed == true and aPressed == false and sPressed == false and dPressed == false then

Does anybody have a solution to my question?

1 answer

✓ Accepted answer

it wont work because you cant put multiple "ands" in an if statement.

That is incorrect. There is no limit on how many times you use and in an if statement.

If the code you provided is not working, it means that wPressed is not the only boolean that is set to true. Try debugging it by using prints to check the variables to see if they are the correct boolean.

1 comment

0

Thank you very much good sir. You saved me a TON of time today.

This discussion is preserved as it was. New answers, comments, and votes are closed.