[Need Help] Regarding image overlay

Hi there,
So I recently tried to make an image of a GPS only be visible when a player is in a vehicle.

client.lua

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(1)
        if IsPedInAnyVehicle(PlayerPedId(), true) then
        display = true
        TriggerEvent('logo:display', true)
    elseif not IsPedInAnyVehicle(PlayerPedId(), true) then
        display = false
        TriggerEvent('logo:display', false)
    end
  end
end)

What I’m trying to achieve
When a player is in a vehicle, they see the mini map and a GPS image.
When a player is walking, the mini-map and GPS image are hidden.

What’s currently occuring
When the player leaves the vehicle, the mini-map hides yet the image remains…

Thanks, I’m sure the answer is right there, but I have been at this for ages and still can’t figure it out. :call_me_hand:

why not just do this

Citizen.CreateThread(function()
  while true do
        Citizen.Wait(1)
        if IsPedInAnyVehicle(PlayerPedId(), true) then
           display = true
           TriggerEvent('logo:display', true)
        else
            display = false
            TriggerEvent('logo:display', false)
        end
  end
end)

Hi mate, thanks for replying.

I updated the code yet the image still remains and I’m not too sure why.

AddEventHandler('onClientMapStart', function()
  Citizen.CreateThread(function()
    local display = false
    local startTime = GetGameTimer()
    local delay = 70000 -- ms

Citizen.CreateThread(function()
  while true do
        Citizen.Wait(1)
        if IsPedInAnyVehicle(PlayerPedId(), true) then
           display = true
           TriggerEvent('logo:display', true)
        else
            display = false
            TriggerEvent('logo:display', false)
        end
  end
end)

local IsPaused = false
Citizen.CreateThread(function()
  while true do
    Citizen.Wait(1)
    if IsPauseMenuActive() and not IsPaused then
      IsPaused = true
      TriggerEvent('logo:display', false)
    elseif not IsPauseMenuActive() and IsPaused then
      IsPaused = false
      TriggerEvent('logo:display', true)
    end
  end
end)

What is the speedometer name?