Get In Closest Vehicle Driver Seat ( Native UI )

Hello, I use a code to get in closest vehicle in driver seat but I get in only if im very close or heading to the vehicle. My code is the following. Any suggestions?

local playerPed = GetPlayerPed()

    local coordA = GetEntityCoords(playerPed, 999999)

    local coordB = GetOffsetFromEntityInWorldCoords(playerPed, 99999999999999.999999, 99999999999.99999999, 9999999999999.99999999)

    local veh = getVehicleInDirection(coordA, coordB)

    if DoesEntityExist(veh) then

        TaskWarpPedIntoVehicle(playerPed , veh, -1)

Kind regards,
Lefos

Please consult the natives reference - you’re not using some of them with the correct (number of) values. Also, there’s no reason to introduce a 99999999999999.999999 value - you can calculate a direction from any non-0 vector (say, +1 offset on an axis)

Thanks for your answer…
I used 20 at first in numbers but then I tried to change it to check if it might change anything.
Whatever, is it easy for you to change the code and bit and send it to me, so I can try it.
That would be very helpful
Kind regards,
Lefos