local Player = game.Players.LocalPlayer
local door = game.Workspace.Ending.Door
local Parts = {
["Part1"] = 1;
["Part2"] = 2;
["Part3"] = 3;
["Part4"] = 4;
}
local Part1 = game.Workspace.Ending.Black
local Part2 = game.Workspace.Ending.Teal
local Part3 = game.Workspace.Ending.Purple
local Part4 = game.Workspace.Ending.Red
local num = 0
Part1.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part1"] == target then
num = num+1
else
num = 0
end
end)
Part2.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part2"] == target then
num = num+1
else
num = 0
end
end)
Part3.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part3"] == target then
num = num+1
else
num = 0
end
end)
Part4.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part4"] == target then
num = 0
door.Transparency = 1
door.CanCollide = false
else
num = 0
end
end)
✓ ANSWER ACCEPTED
How do I make it so this script also detects if you got the wrong pattern?
1 answer
✓ Accepted answer
local Player = game.Players.LocalPlayer
local door = game.Workspace.Ending.Door
local Parts = {
["Part1"] = 1;
["Part2"] = 2;
["Part3"] = 3;
["Part4"] = 4;
}
local Part1 = game.Workspace.Ending.Black
local Part2 = game.Workspace.Ending.Teal
local Part3 = game.Workspace.Ending.Purple
local Part4 = game.Workspace.Ending.Red
local num = 0
local tries = 0
local fail = function()
tries = 0
print("Wrong pattern")
end
Part1.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part1"] == target then
num = num+1
else
num = 0
end
if tries < 3 then
tries = tries+1
else
fail()
end
end)
Part2.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part2"] == target then
num = num+1
else
num = 0
end
if tries < 3 then
tries = tries+1
else
fail()
end
end)
Part3.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part3"] == target then
num = num+1
else
num = 0
end
if tries < 3 then
tries = tries+1
else
fail()
end
end)
Part4.ClickDetector.MouseClick:Connect(function()
local target = num+1
if Parts["Part4"] == target then
num = 0
door.Transparency = 1
door.CanCollide = false
tries = 0
else
num = 0
end
if tries < 3 then
tries = tries+1
else
fail()
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
