local function f(f)local F=f.CFrame.upVector local R=math.deg(math.acos(F:Dot(Vector3.new(0,1,0))))return R>=MIN_FLIP_ANGLE end local function F(F,R)local q=F.Parent.Parent local k=script:WaitForChild("\066\117\116\116\111\110\071\117\105\080\114\111\116\111\116\121\112\101")local b=k:Clone()b.Name="\066\117\116\116\111\110\071\117\105"b.Enabled=true b.Adornee=F.Parent local Q=b:WaitForChild("\066\117\116\116\111\110\073\109\097\103\101")local i=b:WaitForChild("\070\108\105\112\073\109\097\103\101")local V=b:WaitForChild("\066\097\099\107\103\114\111\117\110\100\068\101\115\107\116\111\112")local K=b:WaitForChild("\066\097\099\107\103\114\111\117\110\100\067\111\110\115\111\108\101")local A=b:WaitForChild("\066\117\116\116\111\110\080\114\111\109\112\116")local u local c local J local S if R==Enum.ProximityPromptInputType.Keyboard then u="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\050\053\048\057\048\050"c="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\050\053\048\057\048\050"J="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\050\053\049\053\054\052"S="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\050\053\049\053\054\052"Q.Size=UDim2.new(0,36,0,36)i.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\051\048\055\057\056\051";(i:WaitForChild("\080\114\101\115\115\101\100")).Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\051\048\055\057\056\051"i.Size=UDim2.new(0,44,0,44)K.Visible=false V.Visible=true V.Size=UDim2.new(0,97,0,46)V.Position=UDim2.new(.5,28,.5,0)A.Visible=true A.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\057\051\053\057\049\050\053\051\054"A.Size=UDim2.new(0,36,0,36)A.Position=UDim2.new(.5,-46,.5,0)A.TextLabel.Visible=true A.TextLabel.Text=Keymap.EnterVehicleKeyboard.Name elseif R==Enum.ProximityPromptInputType.Gamepad then u="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\054\051\053\048\050\057"c="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\054\051\053\048\050\057"J="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\054\051\054\053\052\053"S="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\054\051\054\053\052\053"Q.Size=UDim2.new(0,60,0,60)i.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\051\048\055\057\056\051";(i:WaitForChild("\080\114\101\115\115\101\100")).Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\051\048\055\057\056\051"i.Size=UDim2.new(0,44,0,44)V.Visible=false K.Visible=true K.Size=UDim2.new(0,136,0,66)K.Position=UDim2.new(.5,40,.5,0)A.Visible=true A.Size=UDim2.new(0,46,0,46)A.Position=UDim2.new(.5,-63,.5,0)A.ImageRectSize=Vector2.new(71,71)A.ImageRectOffset=Vector2.new(512,600)A.TextLabel.Visible=false local f=InputImageLibrary:GetImageLabel(Keymap.EnterVehicleGamepad,"\076\105\103\104\116")A.Image=f.Image A.ImageRectOffset=f.ImageRectOffset A.ImageRectSize=f.ImageRectSize elseif R==Enum.ProximityPromptInputType.Touch then V.Visible=false K.Visible=false A.Visible=false u="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\055\056\057\056\050\048\048"c="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\055\056\057\056\051\053\052"J="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\050\049\055\056\051\049"S="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\050\049\056\049\048\055"Q.Size=UDim2.new(0,44,0,44)i.Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\049\056\055\053\053\057";(i:WaitForChild("\080\114\101\115\115\101\100")).Image="\114\098\120\097\115\115\101\116\105\100\058\047\047\050\056\052\056\049\056\055\057\056\050"i.Size=UDim2.new(0,44,0,44)Q.InputBegan:Connect(function(f)F:InputHoldBegin()end)Q.InputEnded:Connect(function(f)F:InputHoldEnd()end)i.InputBegan:Connect(function(f)F:InputHoldBegin()end)i.InputEnded:Connect(function(f)F:InputHoldEnd()end)b.Active=true end if f(q)then i.Visible=true Q.Visible=false else i.Visible=false Q.Visible=true end if q.Name=="\086\101\104\105\099\108\101\083\101\097\116"then Q.Image=u Q.Pressed.Image=c else Q.Image=J Q.Pressed.Image=S end return b end ProximityPromptService.PromptShown:Connect(function(f,R)if f.Name=="\069\110\100\111\114\115\101\100\086\101\104\105\099\108\101\080\114\111\120\105\109\105\116\121\080\114\111\109\112\116\086\049"then local q=F(f,R)q.Parent=screenGui f.PromptHidden:Wait()q.Parent=nil end end)
--Tell if a seat is flipped
local function isFlipped(Seat)
	local UpVector = Seat.CFrame.upVector
	local Angle = math.deg(math.acos(UpVector:Dot(Vector3.new(0, 1, 0))))
	return Angle >= MIN_FLIP_ANGLE
end

local function createPrompt(prompt, inputType)
	local seat = prompt.Parent.Parent
	local buttonGui = script:WaitForChild("ButtonGuiPrototype")
	local promptUI = buttonGui:Clone()
	promptUI.Name = "ButtonGui"
	promptUI.Enabled = true
	promptUI.Adornee = prompt.Parent

	local EnterImageButton = promptUI:WaitForChild("ButtonImage")
	local FlipImageButton = promptUI:WaitForChild("FlipImage")
	local BackgroundDesktop = promptUI:WaitForChild("BackgroundDesktop")
	local BackgroundConsole = promptUI:WaitForChild("BackgroundConsole")
	local ButtonPrompt = promptUI:WaitForChild("ButtonPrompt")

	--Switch button type
	local DriverButtonId
	local DriverButtonPressedId
	local PassengerButtonId
	local PassengerButtonPressedId
	if inputType == Enum.ProximityPromptInputType.Keyboard then
		DriverButtonId = "rbxassetid://2848250902"
		DriverButtonPressedId = "rbxassetid://2848250902"
		PassengerButtonId = "rbxassetid://2848251564"
		PassengerButtonPressedId = "rbxassetid://2848251564"
		EnterImageButton.Size = UDim2.new(0, 36, 0, 36)
		FlipImageButton.Image = "rbxassetid://2848307983"
		FlipImageButton:WaitForChild("Pressed").Image = "rbxassetid://2848307983"
		FlipImageButton.Size = UDim2.new(0, 44, 0, 44)

		BackgroundConsole.Visible = false
		BackgroundDesktop.Visible = true
		BackgroundDesktop.Size = UDim2.new(0, 97, 0, 46)
		BackgroundDesktop.Position = UDim2.new(0.5, 28, 0.5, 0)

		ButtonPrompt.Visible = true
		ButtonPrompt.Image = "rbxassetid://2935912536"
		ButtonPrompt.Size = UDim2.new(0, 36, 0, 36)
		ButtonPrompt.Position = UDim2.new(0.5, -46, 0.5, 0)
		ButtonPrompt.TextLabel.Visible = true

		--Display the correct key
		ButtonPrompt.TextLabel.Text = Keymap.EnterVehicleKeyboard.Name
	elseif inputType == Enum.ProximityPromptInputType.Gamepad then
		DriverButtonId = "rbxassetid://2848635029"
		DriverButtonPressedId = "rbxassetid://2848635029"
		PassengerButtonId = "rbxassetid://2848636545"
		PassengerButtonPressedId = "rbxassetid://2848636545"
		EnterImageButton.Size = UDim2.new(0, 60, 0, 60)
		FlipImageButton.Image = "rbxassetid://2848307983"
		FlipImageButton:WaitForChild("Pressed").Image = "rbxassetid://2848307983"
		FlipImageButton.Size = UDim2.new(0, 44, 0, 44)

		BackgroundDesktop.Visible = false
		BackgroundConsole.Visible = true
		BackgroundConsole.Size = UDim2.new(0, 136, 0, 66)
		BackgroundConsole.Position = UDim2.new(0.5, 40, 0.5, 0)

		ButtonPrompt.Visible = true
		--ButtonPrompt.Image = "rbxassetid://408462759"
		ButtonPrompt.Size = UDim2.new(0, 46, 0, 46)
		ButtonPrompt.Position = UDim2.new(0.5, -63, 0.5, 0)
		ButtonPrompt.ImageRectSize = Vector2.new(71, 71)
		ButtonPrompt.ImageRectOffset = Vector2.new(512, 600)
		ButtonPrompt.TextLabel.Visible = false

		--Set the correct image for the gamepad button prompt
		local template = InputImageLibrary:GetImageLabel(Keymap.EnterVehicleGamepad, "Light")
		ButtonPrompt.Image = template.Image
		ButtonPrompt.ImageRectOffset = template.ImageRectOffset
		ButtonPrompt.ImageRectSize = template.ImageRectSize
	elseif inputType == Enum.ProximityPromptInputType.Touch then
		BackgroundDesktop.Visible = false
		BackgroundConsole.Visible = false
		ButtonPrompt.Visible = false

		DriverButtonId = "rbxassetid://2847898200"
		DriverButtonPressedId = "rbxassetid://2847898354"
		PassengerButtonId = "rbxassetid://2848217831"
		PassengerButtonPressedId = "rbxassetid://2848218107"
		EnterImageButton.Size = UDim2.new(0, 44, 0, 44)
		FlipImageButton.Image = "rbxassetid://2848187559"
		FlipImageButton:WaitForChild("Pressed").Image = "rbxassetid://2848187982"
		FlipImageButton.Size = UDim2.new(0, 44, 0, 44)

		EnterImageButton.InputBegan:Connect(function(input)
			prompt:InputHoldBegin()
		end)
		EnterImageButton.InputEnded:Connect(function(input)
			prompt:InputHoldEnd()
		end)
		FlipImageButton.InputBegan:Connect(function(input)
			prompt:InputHoldBegin()
		end)
		FlipImageButton.InputEnded:Connect(function(input)
			prompt:InputHoldEnd()
		end)

		promptUI.Active = true
	end

	if isFlipped(seat) then
		FlipImageButton.Visible = true
		EnterImageButton.Visible = false
	else
		FlipImageButton.Visible = false
		EnterImageButton.Visible = true
	end
	if seat.Name == "VehicleSeat" then
		EnterImageButton.Image = DriverButtonId
		EnterImageButton.Pressed.Image = DriverButtonPressedId
	else
		EnterImageButton.Image = PassengerButtonId
		EnterImageButton.Pressed.Image = PassengerButtonPressedId
	end

	return promptUI
end

ProximityPromptService.PromptShown:Connect(function(prompt, inputType)
	if prompt.Name == "EndorsedVehicleProximityPromptV1" then
		local promptUI = createPrompt(prompt, inputType)
		promptUI.Parent = screenGui
		prompt.PromptHidden:Wait()
		promptUI.Parent = nil
	end
end)
