So I had this script working for something else but I wanted to edit it a bit, but the issue is I’m unsure how to make it work with the new edits I want.
So initially, the script was supposed to work like this: You had a specific order for parts you needed to click in a specific order for something to happen in-game after clicking all those buttons in order.
Here is the script:
local correctPattern = {"Bowler1", "Bowler2", "Bowler3", "Bowler4", "Bowler5", "Bowler6", "Bowler7", "Bowler8", "Bowler9", "Bowler10", "Bowler11", "Bowler12", "Bowler13", "Bowler14", "Bowler15", "Bowler16", "Bowler17", "Bowler18", "Bowler19", "Bowler20", "Bowler21", "Bowler22", "Bowler23", "Bowler24", "Bowler25", "Bowler26", "Bowler27", "Bowler28", "Bowler29", "Bowler30", "Bowler31"} -- etc, the correct pattern.
local current = {} -- table to hold what the user has clicked so far
local count = 1
local buzzer = game.Workspace.Buzzer
local counter = game.StarterGui.CounterGUI.Frame.Counter
-- loop through all the tiles. You should put every "bowler" inside a folder in the
-- workspace called "Bowlers", as it's setup in the script below.
for i,part in pairs(game.Workspace.Bowlers:GetChildren()) do
part.ClickDetector.MouseClick:Connect(function()
table.insert(current, part.Name)
if current[#current] == correctPattern[count] then
print("correct tile")
count += 1
buzzer:Play()
counter.Text = count
else
print("wrong tile")
count = 1
current = {}
end
if count - 1 == #correctPattern then
print("player clicked all tiles correctly")
game.Workspace.ForceField1:Destroy()
game.Workspace.ForceField2:Destroy()
game.Workspace.ForceField3:Destroy()
game.Workspace.ForceField4:Destroy()
game.Workspace.ForceField5:Destroy()
game.Workspace.ForceField6:Destroy()
game.Workspace.ForceField7:Destroy()
game.Workspace.ForceField8:Destroy()
game.Workspace.ForceField9:Destroy()
end
end)
end
Now I wanted to edit the script to be like this: I don’t want it to be “you have to click the buttons in order” I just want it to be so that you only need to click the buttons, but not in order. Also, I added a GUI counter (seen in the picture below) which is supposed to count for each time you click the buttons, so for example if you click one of the buttons it will go from 0 to 1, basically a counter. I couldn’t figure out how to make it work like that either.
I would really appreciate any help to make this work!
Here is the picture of the counter I mentioned before:
Here it is in Explorer under StarterGui: