My multiple conditional script won' work, why?

Hi! So, I have this script:

local ws = game.Workspace

local value1 = ws.firstvalve.Value
local value2 = ws.secondvalve.Value
local value3 = ws.thirdvalve.Value
local value4 = ws.fourthvalve.Value
local value5 = ws.fifthvalve.Value

local TweenService = game:GetService("TweenService")

local door = workspace.Bigmetaldoor
local doorRoot = door.PrimaryPart

local DoorSwingInfo =

local DoorSwingTween = TweenService:Create(doorRoot, DoorSwingInfo, {
    CFrame = doorRoot.CFrame * CFrame.Angles(0, math.rad(-35),0)

local opensound = game.Workspace.Bigmetaldoor.Door.metaldooropen


if value1.Value == true and value2.Value == true then
        script.firstsecond.Value = true

if value3.Value == true and value4.Value == true then
        script.thirdfourth.Value = true

if script.thirdfourth.Value == true and value5.Value == true then
        script.firstfifth.Value = true

if script.firstsecond.Value == true and script.thirdfourth.Value == true then
        script.second.Value = true

if script.second.Value == true and script.firstfifth.Value == true then
        script.all.Value = true

if script.all.Value == true then


What do I want to achieve?
I want to have an script, that checks if all 5 (value1, value2, and so on till 5) conditions are true, and if they are then it should play some animation,etc…

What is the issue?
Currently the issue is when i change the values to True by activating a proximity prompt, then it won’t work. But if I change the values to True by the script like this:

value5.Value = true
value4.Value = true
value3.Value = true
value2.Value = true
value1.Value = true

Then it works…

Useful informations:
Those values are turning to True, when you activate a proximity prompt.
The values which are seen above are a BoolValue.

If you need any more information, please leave a reply!
Thanks for reading! :slightly_smiling_face:

Simple: The code runs once, then it stops. It checks for the values, which are false, and then it reaches the end of the script.

By the way, an if statement takes a true/false value (essentially), and it does the thing if the given value is true. The == operator returns true if the values are equal. Therefore you do not need == true, that says “return true if this thing is true”, you can just use the thing itself.

Also, you can just make an and chain of all values instead of this quite complicated series of if statements.

1 Like

Thanks, but what do you mean by that if statement thing? Can you use it in a code line that maybe be useful for me?

I mean that essentially, an if statement takes a true/false value. If it’s true, it executes the code. Otherwise it skips it.

if true then
    print("hi") --prints hi

if false then
     print("Hello") --doesn't print

And == returns true or false depending on if the values are equal or not.

print(1 == 2) --prints false
print(2 == 2) --prints true

But == true doesn’t make sense if the value at the left is a boolean (true/false) because you want true if it’s true and false if it’s false. You can just use the value itself.

And the last thing I said was that you should use a single if statement with a long condition with multiple ands.

Also, you should connect to the proximity promt triggering if you want to solve the original problem.