# setLightDirection (Client)

> Changes where a spot or rect light points.

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

## Syntax

```lua
bool setLightDirection(light light, float x, y, z)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `light` | `light` | The light. |
| `x, y, z` | `float` | Where the light points. Three numbers or a vec3, finite and non-zero; it is normalised. |

## Returns

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

While the light is attached to another element, the direction is relative to it. A rect light's tangent is made across the new direction again.

## Example

```lua
local light = createSpotLight(2495.1, -1687.4, 20, 0, 0, -1, 25)
addEventHandler("onClientRender", root, function()
    local angle = getTickCount() / 1000
    setLightDirection(light, math.cos(angle), math.sin(angle), -1)
end)
```

### Note

Spot and rect lights only. On a point light it logs a warning and returns `false`.

## See also

- [getLightDirection (Client)](https://wiki.mymp.gg/en/getLightDirection.md): Reads where a spot or rect light points.
- [setLightTangent (Client)](https://wiki.mymp.gg/en/setLightTangent.md): Changes where a rect light's width points, turning the rectangle about its normal.
- [attachElements (Shared)](https://wiki.mymp.gg/en/attachElements.md): Hangs one element on another. From then on it follows the target until it is detached.
