function doesn't return despite there being a return confined in an if statement
local function thething(button, gate, duration, db)
if db then
duration.Value = 10
return
end
button.Transparency = TP + 0.5
gate.Transparency = TP + 0.8
gate.CanCollide = not CC
while duration.Value > 0 do
task.wait(1)
duration.Value -= 1
print(duration.Value)
end
reset(button, gate, duration)
duration.Value = 10
end
the rest of the code:
for _, button in pairs(buttons:GetChildren()) do
local db = false
local db2 = true
local duration = button:FindFirstChild("duration")
button.Touched:Connect(function(hit)
if not hit.Parent:FindFirstChild("Humanoid") then return end
for _, gate in pairs(gates:GetChildren()) do
if button:FindFirstChild("ref").Value == gate:FindFirstChild("ref").Value then
if duration.Value <= 8 and not db then
db = true
print("resetting")
reset(button, gate)
task.wait(1)
db = false
db2 = true
end
if duration.Value ~= 10 and duration.Value > 8 then
print("returning")
return
end
if duration.Value == 10 then
if db2 then
db2 = false
print("proceeding")
thething(button, gate, duration, db)
end
end
end
end
end)
end
