local MainGame = game.Workspace:WaitForChild("mainGame")
local Gates = MainGame:WaitForChild("Gates")
local Buttons = MainGame:WaitForChild("Buttons")
local function activateButton(v, touched) --why do we have v,touched here? Why can't we leave it blank?
touched.Value = true
local gates = Gates:FindFirstChild(v.Name)
local duration = v:FindFirstChild("Duration")
task.wait(duration.Value)
touched.Value = false
end
for _, v in pairs(Buttons:GetChildren()) do
v.Touched:Connect(function(otherPart) --how does it know what v is? like v is the actual parts in the pair right? Not the number order they are in right?
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
local touched = v:FindFirstChild("Touched")
if humanoid and touched and touched.Value == false then
activateButton(v, touched)
end
end)
end