# setLightEnabled (Client)

> Turns a light on or off without destroying it.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Lights
- **URL**: https://wiki.mymp.gg/en/setLightEnabled

## Syntax

```lua
bool setLightEnabled(light light, bool enabled)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `light` | `light` | The light. |
| `enabled` | `bool` | `true` to turn it on, `false` to turn it off. |

## Returns

`true` if it changed. With a wrong argument it logs a warning and returns `false`.

## Example

```lua
local light = createPointLight(2495.1, -1687.4, 14.5, 12)
bindKey("l", "down", function()
    setLightEnabled(light, not isLightEnabled(light))
end)
```

## See also

- [isLightEnabled (Client)](https://wiki.mymp.gg/en/isLightEnabled.md): Tells whether a light is on.
- [createPointLight (Client)](https://wiki.mymp.gg/en/createPointLight.md): Creates a light that shines in every direction from a point. The light exists on this client only.
- [destroyElement (Shared)](https://wiki.mymp.gg/en/destroyElement.md): Destroys an element and all of its children. Before it goes, each one fires onElementDestroy on the server or onClientElementDestroy on the client.
