[ESX Legacy] HUD fade

es_extended\client\main.lua:
find:

-- Pause menu disable HUD display
if Config.EnableHud then
	Citizen.CreateThread(function()
		while true do
			Citizen.Wait(300)

			if IsPauseMenuActive() and not IsPaused then
				IsPaused = true
				TriggerEvent('es:setMoneyDisplay', 0.0)
				ESX.UI.HUD.SetDisplay(0.0)
			elseif not IsPauseMenuActive() and IsPaused then
				IsPaused = false
				TriggerEvent('es:setMoneyDisplay', 1.0)
				ESX.UI.HUD.SetDisplay(1.0)
			end
		end
	end)
end

replace with

-- Pause menu disable HUD display
if Config.EnableHud then
  TriggerEvent('es:setMoneyDisplay', 0.0)
  ESX.UI.HUD.SetDisplay(0.0)
  
	Citizen.CreateThread(function()
		while true do
			Citizen.Wait(300)

			if IsPauseMenuActive() and not IsPaused then
				IsPaused = true
				TriggerEvent('es:setMoneyDisplay', 0.0)
				ESX.UI.HUD.SetDisplay(0.0)
			elseif not IsPauseMenuActive() and IsPaused then
				IsPaused = false
				--TriggerEvent('es:setMoneyDisplay', 1.0)
				--ESX.UI.HUD.SetDisplay(1.0)
			end
		end
	end)
  Citizen.CreateThread(function()
		while true do
			Citizen.Wait(10)

			if IsControlJustReleased(0, Keys['Z']) then
        fadeInHUD()
      end
		end
	end)
end

and add:

function fadeOutHUD()
  local fade_value = 1.0
  while fade_value > 0.0 do
    Citizen.Wait(1)
    TriggerEvent('es:setMoneyDisplay', fade_value)
    ESX.UI.HUD.SetDisplay(fade_value)
    fade_value = fade_value - 0.1
  end
end

function fadeInHUD()
  local fade_value = 0.0
  while fade_value < 1.0 do
    Citizen.Wait(1)
    TriggerEvent('es:setMoneyDisplay', fade_value)
    ESX.UI.HUD.SetDisplay(fade_value)
    fade_value = fade_value + 0.1
  end
  Citizen.Wait(5000) -- start fade out after 5 seconds
  fadeOutHUD()
end

Now, when you press Z, your hud will fade in and be visible for 5 seconds, and then fade back out.