Use boolvalues and a manager script. On change of any of the boolvalues, check if the other ones are completed in the right way, then unlock the door. Else, don’t unlock the door.
Use a table. For example, using table.insert() you can have an order like
stepsToComplete = {
1,
2,
3
}
stepsTaken = {}
When one of the boolvalues changes, if the value is true then insert it into the stepsTaken table. Once the stepstaken table reaches 3 numbers inside it, compare it to the stepsToComplete table
local tasks = {
false,
false,
false
} --? Add a "false" for each uncompleted task
local function resetTasks()
for i, v in ipairs(tasks) do
tasks[i] = false
end
end
local function isTaskFinished(task: number): boolean
return tasks[task]
end
local function finishTask(task: number)
if not isTaskFinished(task - 1) then --? Task before this wasn't finished
resetTasks()
return false --? Failed
end
tasks[task] = true
return true --? Succeeded
end
Something like this should work, I made each thing a function in case you wanted to edit how tasks are counted as finished or how to make them finished or how to reset them.
To use it, just do this:
local isCompleted = finishTask(2)
if not isCompleted then
--? Tell the user he did it in the wrong order
end
--? The user is doing them in the right order
local puzzle = {
[1] = 1,
[2] = 3,
[3] = 2,
}
if puzzle[1] == 1 and puzzle[2] == 2 and puzzle[3] == 3 then -- if valve order is 123
-- unlock door
elseif -- if valve order is not 123
-- reset puzzle
puzzle[1] = 0
puzzle[2] = 0
puzzle[3] = 0
-- door does not unlock
end
since the puzzle is 132, the door will not open and the puzzle will reset