I want to detect what pattern buttons were pressed. Like if the player pressed part1 first, and then part3, and then part2, and lastly part 4. Then, if they pressed part1 first, part2 second, part3 third, part4 last a part would turn transparent.
b3wz's idea is good, this is mine:
01 | local Player = game.Players.LocalPlayer |
02 | local Door = game.Workspace.Door |
03 | local Parts = { |
04 | [ "Part1" ] = 1 ; |
05 | [ "Part2" ] = 2 ; |
06 | [ "Part3" ] = 3 ; |
07 | } |
08 | local Part 1 = game.Workspace.Part 1 |
09 | local Part 2 = game.Workspace.Part 2 |
10 | local Part 3 = game.Workspace.Part 3 |
11 | local num = 0 |
12 |
13 | Part 1. ClickDetector.MouseClick:Connect( function () |
14 | local target = num+ 1 |
15 | if Parts [ "Part1" ] = = target then |
This is an idea on how you can do it:
01 | local Pressed = { } |
02 |
03 | -- when you listen to buttons being pressed do something like this maybe |
04 | if #Pressed > 4 then |
05 | table.insert(Pressed, button.Name) |
06 | else |
07 | if Pressed [ 1 ] = = "Button1" and Pressed [ 2 ] = = "Button2" and Pressed [ 3 ] = = "Button3" and Pressed [ 4 ] = = "Button4" then |
08 | -- make part transparent |
09 | end |
10 | Pressed = { } |
11 | end |
Might not be the best way to do it but was the first idea that came to my head