guiSetAlpha | Multi Theft Auto: Wiki Skip to content

guiSetAlpha

Client-side
Server-side
Shared

Pair: guiGetAlpha

This changes the alpha level (the visibleness/transparency) of a GUI element.

OOP Syntax Help! I don't understand this!

Syntax

bool guiSetAlpha ( ​gui-element theElement, ​float alpha )
Required arguments
  • theElement: The GUI element whose visibility is to be changed.
  • alpha: The visibility/transparency of the GUI element. Ranges from 0 (fully transparent) to 1 (fully opaque). Default value is 0.80.

Returns

Returns true if the gui element's alpha was successfully changed, false otherwise.

  • bool: result

Code Examples

client

This creates a GUI window and allows a player to change it's alpha (the visibleness/transparency) value with a command.

local myWindow = guiCreateWindow(0.30, 0.10, 0.5, 0.60, "GUI window title", true)
-- Add a command handler to change the alpha of the GUI window.
-- Usage example: '/windowAlpha 0.8', where 0.8 is stored as alphaAmount
function changeAlpha(commandName, alphaAmount)
if (not tonumber(alphaAmount)) then
return
end
guiSetAlpha(myWindow, tonumber(alphaAmount))
end
addCommandHandler("windowAlpha", changeAlpha)

See Also

GUI Functions