[HELP] Two actions in one button

Hi guys,

I have a problem which I can’t solve …
When we press the button F7, if the telephone is opened, I wish to close it thanks to the function closeGui, otherwise, if the telephone is closed, I wish to open it thanks to the function openGui.

For the moment, I manage to open it but not to close it… I don’t manage to enter the function closeGui…

Can you help me please?

My script :

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        ------------- 168 = F7 --------------
        if IsControlJustPressed(1, 168) then
            if phoneOpen then
                closeGui()
                phoneOpen = false
            else
                openGui()
                phoneOpen = true
            end
        end
    end
end)

Thanks in advance.

2 Likes