Aiming at ped so that they step out of the vehicle

Hey guys! So I’m currently trying to make a script where whenever I aim at a ped that sits in a vehicle to step out of the vehicle instead of running over me. The script I have written so far is like this. Even when I aim at a ped in a vehicle it doesn’t print anything either.

ESX = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)    

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)

        local player = GetPlayerPed(-1)
        local playerweapon = IsPedArmed(player, 4)
        
        local ped = GetEntityPlayerIsFreeAimingAt(player)

        if ped then 
            if DoesEntityExist(ped) and isEntityAPed(ped) then
                print("Working")
                local pedvehicle = GetVehiclePedIsIn(ped, false)
                TaskLeaveVehicle(ped, pedvehicle, 256)
            end
        end
    end
end)

IsEntityAPed(ped). Capitalisation mistake?

Also, GetEntityPlayerIsFreeAimingAt expects a PLAYER object. Hence, PlayerId(), not your own PED

Feel free to pull this apart to help you write your own: