So, I've wanted to do a multiple(5) condition checks, in a script. Basically there's 5 values in different parts and if the proximityprompts trigger they change 1 value, and there are 5 of those, and if those 5 values are all true, then it should play the animation and the sound. But the problem is: if i tell the script to change every value on its own like:
value5.Value = true
value4.Value = true
value3.Value = true
value2.Value = true
value1.Value = true
Then it's working but I wanted so if the player activates all of the values with the proximity prompt then it should play the animation,etc... Here's the 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 = TweenInfo.new()
local DoorSwingTween = TweenService:Create(doorRoot, DoorSwingInfo, {
CFrame = doorRoot.CFrame * CFrame.Angles(0, math.rad(-35),0)
})
local opensound = game.Workspace.Bigmetaldoor.Door.metaldooropen
print("start")
if value1.Value == true and value2.Value == true then
script.firstsecond.Value = true
print("count")
end
if value3.Value == true and value4.Value == true then
script.thirdfourth.Value = true
print("count")
end
if script.thirdfourth.Value == true and value5.Value == true then
script.firstfifth.Value = true
print("count")
end
if script.firstsecond.Value == true and script.thirdfourth.Value == true then
script.second.Value = true
print("count")
end
if script.second.Value == true and script.firstfifth.Value == true then
script.all.Value = true
print("count")
end
if script.all.Value == true then
DoorSwingTween:Play()
opensound:Play()
print("done")
end
Thanks for reading, and all the helping that you guys give! I'm very thankful!

1 comment
i cant find the problem here,but i wanna suggest u to use only one value and increase it 1 by 1 every time proximityprompts trigger,it should be more efficient