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

How can I compare multiple variables?

Asked by
ded_srs 30
4 years ago
Edited 4 years ago

I want to compare 3 variables to see if they have the same value as a 4th variable. I tried using the "and" operator.

if a and b and c == d then
    print("correct")
end

However, I found out that "and" can only be used between 2 variables. Is there an alternate operator that I can use?

Many thanks.

1 answer

Log in to vote
1
Answered by
mattscy 3725 Moderation Voter Community Moderator
4 years ago

You have to make sure you compare each variable with d individually

if a == d and b == d and c == d then
    print("correct")
end

Hope this helps!

0
Thank you! ded_srs 30 — 4y
0
Glad I could help! For future reference, you can mark answers as accepted if they answer your question. mattscy 3725 — 4y
Ad

Answer this question