local function D()local D=LocalPlayer.Character Died=false HRP=D:WaitForChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")Humanoid=D:WaitForChild("\072\117\109\097\110\111\105\100");(Humanoid:GetPropertyChangedSignal("\083\105\116")):Connect(function()if Humanoid.Sit then hidePrompt()end end)Humanoid.Died:Connect(function()Died=true hidePrompt()end)end LocalPlayer.CharacterAdded:Connect(D)if LocalPlayer.Character then D()end local function q()if HRP and Humanoid then if not Humanoid.Sit and not Died then local D=math.huge local q=nil local u=nil for n,B in pairs(CollectionService:GetTagged("\069\110\100\111\114\115\101\100\086\101\104\105\099\108\101"))do local y=B:WaitForChild("\083\099\114\105\112\116\115")local X=y and require(y:WaitForChild("\076\111\099\097\108\086\101\104\105\099\108\101\083\101\097\116\105\110\103"))local Z=X.GetSeats()for n,B in pairs(Z)do local y,Z=Workspace.CurrentCamera:WorldToViewportPoint(B.Position)if Z then local n=(HRP.Position-B.Position).magnitude if n<D and(n<MAX_PROMPT_DISTANCE and not B:FindFirstChild("\083\101\097\116\087\101\108\100"))then D=n q=B u=X end end end end return q,u end end end while script.Parent~=nil do local D,u=q()if D and not(Humanoid.Sit or Humanoid.PlatformStand)then if D~=AdornedSeat then hidePrompt()AdornedSeat=D AdornedSeatModule=u u.ShowPrompt(D,script.Parent)end elseif AdornedSeat then hidePrompt()end wait(SEAT_POLL_INTERVAL)end

local function characterAdded()
	local character = LocalPlayer.Character
	Died = false
	HRP = character:WaitForChild("HumanoidRootPart")
	Humanoid = character:WaitForChild("Humanoid")
	Humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
		if Humanoid.Sit then
			hidePrompt()
		end
	end)
	Humanoid.Died:Connect(function()
		Died = true
		hidePrompt()
	end)
end

LocalPlayer.CharacterAdded:Connect(characterAdded)
if LocalPlayer.Character then
	characterAdded()
end

local function getClosestSeat()
	if HRP and Humanoid then
		if not Humanoid.Sit and not Died then
			local closest = math.huge
			local closestSeat = nil
			local closestModule = nil

			for _, vehicle in pairs(CollectionService:GetTagged("EndorsedVehicle")) do
				local scripts = vehicle:WaitForChild("Scripts")
				local seatingModule = scripts and require(scripts:WaitForChild("LocalVehicleSeating"))
				local seats = seatingModule.GetSeats()

				for _, seat in pairs(seats) do
					local _, seatVisible = Workspace.CurrentCamera:WorldToViewportPoint(seat.Position)
					if seatVisible then
						local dist = (HRP.Position - seat.Position).magnitude
						if dist < closest and dist < MAX_PROMPT_DISTANCE and not seat:FindFirstChild("SeatWeld") then
							closest = dist
							closestSeat = seat
							closestModule = seatingModule
						end
					end
				end
			end

			return closestSeat, closestModule
		end
	end
end

while script.Parent ~= nil do
	local closestSeat, closestModule = getClosestSeat()
	if closestSeat and (not (Humanoid.Sit or Humanoid.PlatformStand)) then
		if closestSeat ~= AdornedSeat then
			hidePrompt()
			AdornedSeat = closestSeat
			AdornedSeatModule = closestModule
			closestModule.ShowPrompt(closestSeat, script.Parent)
		end
	elseif AdornedSeat then
		hidePrompt()
	end
	wait(SEAT_POLL_INTERVAL)
end
