# setElementAlpha (Shared)

> Sets the transparency of an element and of all its children.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Elements
- **URL**: https://wiki.mymp.gg/en/setElementAlpha

## Syntax

```lua
bool setElementAlpha(element element, int alpha)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element. |
| `alpha` | `int` | Opacity, an integer from 0 (invisible) to 255 (opaque). |

## Returns

`true` if it applied to the element itself, `false` if not. Raises an error if `alpha` is outside 0 to 255.

## Example

```lua
addCommandHandler("ghost", function(player)
    setElementAlpha(player, 120)
end)
```

## See also

- [getElementAlpha (Shared)](https://wiki.mymp.gg/en/getElementAlpha.md): Reads an element's alpha, from 0 (invisible) to 255 (opaque).
