guiSetVisible | Multi Theft Auto: Wiki Skip to content

guiSetVisible

Client-side
Server-side
Shared

Pair: guiGetVisible

This function changes the visibility state of a GUI element.

OOP Syntax Help! I don't understand this!

  • Method:gui-element:setVisible(...)
  • Variable: .visible

Syntax

bool guiSetVisible ( ​gui-element guiElement, ​bool state )
Required arguments
  • guiElement: The GUI element whose visibility is to be changed.
  • state: The new visibility state.

Returns

Returns true if the element's visibility could be changed, false otherwise.

  • bool: result

Code Examples

client

This example creates a GUI window and changes its visibility every 2 seconds, indefinitely.

-- Create a GUI window called 'myWindow'
local myWindow = guiCreateWindow(0.3, 0.3, 0.5, 0.60, "GUI window title", true)
-- Set a timer to change the window's visibility every 2 seconds, indefinitely
setTimer(function()
-- We toggle the visibility here by taking the opposite result of guiGetVisible (false => true, true => false), hence toggling its visibility
guiSetVisible(myWindow, not guiGetVisible(myWindow))
end, 2000, 0)

See Also

GUI Functions