How to check if an event has been triggered

I don’t know if this is the sub forum to go to but I guess it is

I was watching youtube tutorials on how to do lua and fivem and basically the guy in the video made a command to turn on an NUI, but I wanted to make it so when you press a key it show you the nui or it turns it off, but I don’t know how to make the if statement to check which event has been triggered, this is the code:

Citizen.CreateThread(function()

	local e_key = 51
	while true do
		Citizen.Wait(1)
		if IsControlJustReleased(1, e_key) then
			if 'nui:on' then
	      		TriggerEvent('nui:off', true)
				notif("~b~Norint išjungti lentelę spauskite ~INPUT_CONTEXT~")
			else
	      		TriggerEvent('nui:on', true)
				notif("~b~Norint įjungti lentelę spauskite ~INPUT_CONTEXT~")
			end
		end
	end

end)
  RegisterNetEvent('nui:on')
  AddEventHandler('nui:on', function()
    SendNUIMessage({
      type = "ui",
      display = true
    })
  end)

  RegisterNetEvent('nui:off')
  AddEventHandler('nui:off', function()
    SendNUIMessage({
      type = "ui",
      display = false
    })
  end)

EDIT:
Also could I just make it if ‘nui:on’ = true then… ? something like that, I’m new to lua , but I had some experience in samp scripting

I found out, someone can close this topic

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.