--[[ diag_paexit.luau -- work out the real route from the SpawnPad out of the Daikoku PA and onto the wangan mainline. Reports, in world coordinates: the spawn pad, the ring road, both ramps, and -- crucially -- the COMPASS BEARING and distance from the pad to each ramp, so the answer can be phrased as "drive X studs toward " rather than a vague description. Bearings are given in Roblox world terms: -Z is treated as North. ]] local Workspace = game:GetService("Workspace") local out = {} local function log(s) table.insert(out, s) end local map = Workspace:FindFirstChild("Map") if not map then return "FATAL: no Map in Workspace -- build the map first (Play once)" end local function grab(name) local hit = map:FindFirstChild(name, true) return (hit and hit:IsA("BasePart")) and hit or nil end local pad = grab("SpawnPad") if not pad then return "FATAL: SpawnPad not found under Map" end log( string.format( "SpawnPad pos=(%.0f, %.0f, %.0f) size=(%.0f x %.0f)", pad.Position.X, pad.Position.Y, pad.Position.Z, pad.Size.X, pad.Size.Z ) ) -- Compass bearing from the pad to a target, with -Z = North. local function bearing(from, to) local d = Vector3.new(to.X - from.X, 0, to.Z - from.Z) if d.Magnitude < 0.01 then return "--", 0 end local deg = math.deg(math.atan2(d.X, -d.Z)) -- 0 = -Z (north), +90 = +X (east) if deg < 0 then deg += 360 end local names = { "North", "NE", "East", "SE", "South", "SW", "West", "NW" } local idx = math.floor(((deg + 22.5) % 360) / 45) + 1 return names[idx], d.Magnitude, deg end log("") log("--- ramps and ring ---") for _, nm in ipairs({ "PAOnRamp", "PAOffRamp" }) do local p = grab(nm) if p then local dir, dist, deg = bearing(pad.Position, p.Position) log( string.format( "%-10s pos=(%.0f, %.0f, %.0f) %s of pad, %.0f studs, bearing %.0f deg", nm, p.Position.X, p.Position.Y, p.Position.Z, dir, dist, deg or 0 ) ) else log(string.format("%-10s NOT FOUND", nm)) end end -- Ring segments: report the ring's radius and height vs the pad. local ringParts = {} for _, d in ipairs(map:GetDescendants()) do if d:IsA("BasePart") and (d.Name:find("Ring") or d.Name == "PARing") then table.insert(ringParts, d) end end if #ringParts > 0 then local minY, maxY = math.huge, -math.huge local maxR = 0 for _, p in ipairs(ringParts) do minY = math.min(minY, p.Position.Y) maxY = math.max(maxY, p.Position.Y) local r = (Vector3.new(p.Position.X - pad.Position.X, 0, p.Position.Z - pad.Position.Z)).Magnitude maxR = math.max(maxR, r) end log( string.format( "ring %d parts, radius up to %.0f studs, Y %.0f..%.0f (pad Y %.0f)", #ringParts, maxR, minY, maxY, pad.Position.Y ) ) log(string.format(" ring sits %.0f studs ABOVE the pad", minY - pad.Position.Y)) end -- Where is the mainline relative to the pad? log("") log("--- mainline ---") local roadFolder = map:FindFirstChild("Road") or map:FindFirstChild("Circuit") if roadFolder then local nearest, nearestD = nil, math.huge for _, d in ipairs(roadFolder:GetDescendants()) do if d:IsA("BasePart") then local dist = (Vector3.new(d.Position.X - pad.Position.X, 0, d.Position.Z - pad.Position.Z)).Magnitude if dist < nearestD then nearestD, nearest = dist, d end end end if nearest then local dir, dist = bearing(pad.Position, nearest.Position) log( string.format( "nearest mainline part '%s' at (%.0f, %.0f, %.0f)", nearest.Name, nearest.Position.X, nearest.Position.Y, nearest.Position.Z ) ) log( string.format( " -> %s of the pad, %.0f studs away, Y %+.0f vs pad", dir, dist, nearest.Position.Y - pad.Position.Y ) ) end else local names = {} for _, d in ipairs(map:GetChildren()) do table.insert(names, d.Name) end log("no Road/Circuit folder; Map children: " .. table.concat(names, ", ")) end return table.concat(out, "\n")