Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I detect what pattern buttons were pressed?

Asked by 5 years ago

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.

2 answers

Log in to vote
1
Answered by
karlo_tr10 1233 Moderation Voter
5 years ago

b3wz's idea is good, this is mine:

01local Player = game.Players.LocalPlayer
02local Door = game.Workspace.Door
03local Parts = {
04["Part1"] = 1
05["Part2"] = 2;
06["Part3"] = 3
07}
08local Part1 = game.Workspace.Part1
09local Part2 = game.Workspace.Part2
10local Part3 = game.Workspace.Part3
11local num = 0
12 
13Part1.ClickDetector.MouseClick:Connect(function()
14    local target = num+1
15    if Parts["Part1"] == target then
View all 40 lines...
Ad
Log in to vote
2
Answered by
b3wz 34
5 years ago

This is an idea on how you can do it:

01local Pressed = {}
02 
03-- when you listen to buttons being pressed do something like this maybe
04if #Pressed > 4 then
05    table.insert(Pressed, button.Name)
06else
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 = {}
11end

Might not be the best way to do it but was the first idea that came to my head

0
What would be the location? GamingWithFlight 80 — 5y

Answer this question