I didn’t know if I could look it up on the internet so I’m writing here, my problem is that there are 4 boolvalues and I want to put them in order, so I need to know which one is true first or which one is true 3rd.
Right switch pulled.
Left switch pulled.
Middle switch is pulled.
Back switch is pulled.
Something like this {First pulled switch “Right switch”, Second pulled switch “Middle switch”, Third pulled switch “Back switch”, last pulled switch “Left switch”}
print will be enough, my main goal here is that I have 4 switches and when we open them in the correct order, they will open a door.
And if all the switches are open at the end and the order is printed, after 1 minute all boolvalues will be false and the door will close.
i’ve got a general idea on how to do this but is this a case where you only know whether you got it right after you pull all 4 , Or they will reset the moment you get one of them wrong
I was thinking that after all four of the switches are pulled, if they are not correct, they will return to their original state, if they are correct, they will stay that way until the door is closed again.
ok then here is a way to do this, you don’t need to use booleans :
First we create a string with our reference correct order
local CorrectOrder = "RLMB" -- Right,Left,Middle,Back
then we create a string where we store the pulled switches and add the letter refferring to that switch
local CurrentOrder = ""
-- when a switch is pulled depending on the switch you do
CurrentOrder.."L" -- for example when Left is pulled
When all four switches are pulled we just check if the 2 strings match
local function IsCorrectOrder()
if #CurrentOrder == 4 then
if CorrectOrder == CurrentOrder then
--Open Door
else
--Reset all switches
CurrentOrder = ""
end
end
end
-- whenever a switch is pulled you do a check using the function above
IsCorrectOrder()
uh yeah i dont know what to do now, i have switches can change booleans but how can i use them with script you gived, they have seperate scripts for each switch
sorry for late reply i suppose you figured it out since you marked it as solution but if you haven’t then put all of the switches interaction in one script
well actually i didnt understanded , but i found a way to do it , its long but working so far `local hardopen = script.Parent[“LeverModel(Hard)”].Lever.Opened
local normalopen = script.Parent[“LeverModel(Normal)”].Lever.Opened
local easyopen = script.Parent[“LeverModel(Easy)”].Lever.Opened
local whiteopen = script.Parent[“LeverModel(White)”].Lever.Opened
if normalopen.Value == false and easyopen.Value == false and whiteopen.Value == false then
print("1. Pulled Lever is Red")
else if normalopen.Value == true and easyopen.Value == false and whiteopen.Value == false then
print("2. Pulled Lever is Red")
else if normalopen.Value == false and easyopen.Value == true and whiteopen.Value == false then
print("2. Pulled Lever is Red")
else if normalopen.Value == false and easyopen.Value == false and whiteopen.Value == true then
print("2. Pulled Lever is Red")
else if normalopen.Value == false and easyopen.Value == true and whiteopen.Value == true then
print("3. Pulled Lever is Red")
else if normalopen.Value == true and easyopen.Value == true and whiteopen.Value == false then
print("3. Pulled Lever is Red")
else if normalopen.Value == true and easyopen.Value == false and whiteopen.Value == true then
print("3. Pulled Lever is Red")
else if normalopen.Value == true and easyopen.Value == true and whiteopen.Value == true then
print("4. Pulled Lever is Red")
end
end
end
end
end
end
end
end
end)
normalopen:GetPropertyChangedSignal(“Value”):Connect(function(Value)
if easyopen.Value == false and hardopen.Value == false and whiteopen.Value == false then
print(“1. Pulled Lever is Yellow”)
else if easyopen.Value == true and hardopen.Value == false and whiteopen.Value == false then
print(“2. Pulled Lever is Yellow”)
else if easyopen.Value == false and hardopen.Value == true and whiteopen.Value == false then
print(“2. Pulled Lever is Yellow”)
else if easyopen.Value == false and hardopen.Value == false and whiteopen.Value == true then
print(“2. Pulled Lever is Yellow”)
else if easyopen.Value == false and hardopen.Value == true and whiteopen.Value == true then
print(“3. Pulled Lever is Yellow”)
else if easyopen.Value == true and hardopen.Value == true and whiteopen.Value == false then
print(“3. Pulled Lever is Yellow”)
else if easyopen.Value == true and hardopen.Value == false and whiteopen.Value == true then
print(“3. Pulled Lever is Yellow”)
else if easyopen.Value == true and hardopen.Value == true and whiteopen.Value == true then
print(“4. Pulled Lever is Yellow”)
end
end
end
end
end
end
end
end
end)
easyopen:GetPropertyChangedSignal(“Value”):Connect(function(Value)
if normalopen.Value == false and hardopen.Value == false and whiteopen.Value == false then
print(“1. Pulled Lever is Green”)
else if normalopen.Value == true and hardopen.Value == false and whiteopen.Value == false then
print(“2. Pulled Lever is Green”)
else if normalopen.Value == false and hardopen.Value == true and whiteopen.Value == false then
print(“2. Pulled Lever is Green”)
else if normalopen.Value == false and hardopen.Value == false and whiteopen.Value == true then
print(“2. Pulled Lever is Green”)
else if normalopen.Value == false and hardopen.Value == true and whiteopen.Value == true then
print(“3. Pulled Lever is Green”)
else if normalopen.Value == true and hardopen.Value == true and whiteopen.Value == false then
print(“3. Pulled Lever is Green”)
else if normalopen.Value == true and hardopen.Value == false and whiteopen.Value == true then
print(“3. Pulled Lever is Green”)
else if normalopen.Value == true and hardopen.Value == true and whiteopen.Value == true then
print(“4. Pulled Lever is Green”)
end
end
end
end
end
end
end
end
end)
whiteopen:GetPropertyChangedSignal(“Value”):Connect(function(Value)
if normalopen.Value == false and hardopen.Value == false and easyopen.Value == false then
print(“1. Pulled Lever is White”)
else if normalopen.Value == true and hardopen.Value == false and easyopen.Value == false then
print(“2. Pulled Lever is White”)
else if normalopen.Value == false and hardopen.Value == true and easyopen.Value == false then
print(“2. Pulled Lever is White”)
else if normalopen.Value == false and hardopen.Value == false and easyopen.Value == true then
print(“2. Pulled Lever is White”)
else if normalopen.Value == false and hardopen.Value == true and easyopen.Value == true then
print(“3. Pulled Lever is White”)
else if normalopen.Value == true and hardopen.Value == true and easyopen.Value == false then
print(“3. Pulled Lever is White”)
else if normalopen.Value == true and hardopen.Value == false and easyopen.Value == true then
print(“3. Pulled Lever is White”)
else if normalopen.Value == true and hardopen.Value == true and easyopen.Value == true then
print(“4. Pulled Lever is White”)
end
end
end
end
end
end
end
end
end)`
this is an example of a badly written code. You DONT want to write your code like this…
First of all it’s hardly understandable so if you happen to come back to it months or just weeks later not even you will understand what you’re doing here.
Also i’m not entirely sure how this is working but if you want to change the sequence wouldn’t you need to change everything again… anyway i’ll help you by implementing what i wrote earlier since now i know what’s going on better :
local hardopen = script.Parent["LeverModel(Hard)"].Lever.Opened
local normalopen = script.Parent["LeverModel(Normal)"].Lever.Opened
local easyopen = script.Parent["LeverModel(Easy)"].Lever.Opened
local whiteopen = script.Parent["LeverModel(White)"].Lever.Opened
local CorrectOrder = "WNEH" -- White,Normal,Easy,Hard
local CurrentOrder = ""
local function IsCorrectOrder()
if #CurrentOrder == 4 then
if CorrectOrder == CurrentOrder then
--Open Door
else
--Reset all switches
hardopen.Value = false
normalopen.Value = false
easyopen.Value = false
whiteopen.Value = false
CurrentOrder = ""
end
end
end
local function ManageOrderString(Letter,value)
if value then
CurrentOrder = CurrentOrder..Letter -- Adding the Letter to the string "W" for example
IsCorrectOrder() --Checking if all 4 have been pulled
else
if string.sub(CurrentOrder, -1) == Letter then -- if the last character is Letter(we just pulled the same switch)
CurrentOrder:sub(1, -2) --Remove last character from string
else
--This will run if the switch we just turned off wasn't the last one we pulled
--For example we pulled normal then hard then easy and came back and turned off normal
--In this case you can Reset All switches (Create a function that does turns all values to false and resets the switches visually too)
end
end
end
whiteopen.Changed:Connect(function(value)
ManageOrderString("W",value)
end)
hardopen.Changed:Connect(function(value)
ManageOrderString("H",value)
end)
easyopen.Changed:Connect(function(value)
ManageOrderString("E",value)
end)
normalopen.Changed:Connect(function(value)
ManageOrderString("N",value)
end)