does this part of the script :
local gate = gates:FindFirstChild(button.Name)
correspond to the button that has the same name as the gate?
local mg = game.Workspace:WaitForChild("Maingame")
local buttons = mg:WaitForChild("Button")
local gates = mg:WaitForChild("Gate")
local function ab(button, touched)
touched.Value = true
local gate = gates:FindFirstChild(button.Name)
if gate then
gate.Transparency = 0.5
gate.CanCollide = false
end
local duration = button:FindFirstChild("Duration")
local timer = duration.Value
while timer>0 do
print(timer)
task.wait(1)
timer -= 1
end
gate.Transparency = 0
gate.CanCollide = true
touched.Value = false
end
for _, button in pairs(buttons:GetChildren()) do
button.Touched:Connect(function(otherpart)
local humanoid = otherpart.Parent:FindFirstChild("Humanoid")
local touched = button:FindFirstChild("Touched")
if humanoid and touched and touched.Value == false then
ab(button, touched)
end
end)
end
** You are now Level 2! **