-- Median opening test, now against the CORRECT part name. The centre divider -- is "Median_"; "Barrier" is the outer edge parapet (which must NOT open). local ws = game:GetService("Workspace") local map = ws:FindFirstChild("Map") local medians, roads = {}, {} for _, d in ipairs(map:GetDescendants()) do if d:IsA("BasePart") then local b = d.Name:gsub("_?%d+$", "") if b == "Median" then table.insert(medians, d.Position) elseif b == "Road" then table.insert(roads, d.Position) end end end local anchors = {} for _, d in ipairs(map:GetDescendants()) do if d:IsA("BasePart") and (d.Name == "PAEntryRampNear_200" or d.Name == "PAExitRampNear_200") then table.insert(anchors, { d.Name, d.Position }) end end local WIN = 220 local function countNear(pos, list) local n = 0 for _, bp in ipairs(list) do if (Vector3.new(pos.X, 0, pos.Z) - Vector3.new(bp.X, 0, bp.Z)).Magnitude < WIN then n += 1 end end return n end local out = {} table.insert(out, ("medianParts=%d roadParts=%d window=+/-%d"):format(#medians, #roads, WIN)) local ctrl = {} local step = math.max(1, math.floor(#roads / 14)) for i = 1, #roads, step do local p = roads[i] local far = true for _, a in ipairs(anchors) do if (Vector3.new(p.X, 0, p.Z) - Vector3.new(a[2].X, 0, a[2].Z)).Magnitude < 700 then far = false end end if far then table.insert(ctrl, countNear(p, medians)) end end table.sort(ctrl) local sum = 0 for _, v in ipairs(ctrl) do sum += v end table.insert( out, ("CONTROL plain mainline (n=%d): min=%d median=%d max=%d mean=%.1f"):format( #ctrl, ctrl[1] or -1, ctrl[math.max(1, math.floor(#ctrl / 2))] or -1, ctrl[#ctrl] or -1, #ctrl > 0 and sum / #ctrl or -1 ) ) for _, a in ipairs(anchors) do table.insert(out, ("JUNCTION %s: mediansInWindow=%d"):format(a[1], countNear(a[2], medians))) end return table.concat(out, "\n")