Bomb Bay Help

Hello, I recently created a client script that is supposed to open and close the bomb bay on a vehicle, however it does not work. This is the code:

local veh = GetVehiclePedIsIn(PlayerPedId(), false)

Citizen.CreateThread(function()

while true do

Wait(0)

    if IsControlJustPressed(1,167) then

    OpenBombBayDoors(veh)

    elseif IsControlJustPressed(1,167) then

    CloseBombBayDoors(veh)

    end

end

end)

Does anyone know why this is not working? (ps: I just started scripting and I’m sure I did something wrong just don’t know what I did wrong) Thanks!