[HELP] Toggle Key

i have put this code in but i have no idea how to make it toggle, right now it only works if i hold the key but i want it to toggle the text. if someone could help i would appreciate it since i am not that good with code.

function DrawText2(x,y ,width,height,scale, text, r,g,b,a)
    if not HideHud then
        SetTextFont(4)
        SetTextProportional(0)
        SetTextScale(0.35, 0.35)
        SetTextColour(r, g, b, a)
        SetTextDropShadow(0, 0, 0, 0,255)
        SetTextEdge(2, 0, 0, 0, 255)
        SetTextDropShadow()
        SetTextOutline()
        SetTextEntry("STRING")
        AddTextComponentString(text)
        DrawText(x - width/2, y - height/2 + 0.005)
	end	
end

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

		if IsControlPressed(1, 57) and GetLastInputMethod(1) then
			Citizen.Wait(0)

			HideHud = false
		else
			HideHud = true
		end
	end
end)

Your function get’s nowhere triggered there?

Anyway, do this:

if HideHud == false or HideHud == nil then
            HideHud = true
		else
			HideHud = false
end

Thank you so much i’ll try it.
Edit.
it worked thanks for taking the time to help me out.

1 Like