# getClosestPathNode (Shared)

> Finds the road or footpath node closest to a point.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Roads and paths
- **URL**: https://wiki.mymp.gg/en/getClosestPathNode

## Syntax

```lua
int, vec3|false getClosestPathNode(float x, y, z [, string type = car, bool water = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `x, y, z` | `float` | The point to search from. |
| `type` | `string` | `car` for roads, `ped` for footpaths. *(default: `car`)* |
| `water` | `bool` | `true` searches only the boat paths on water; `false`, only on land. *(default: `false`)* |

## Returns

The node's id and its position, or `false` if no node was found.

A node id joins the path area (750 m wide) and the node's index in it: `area << 16 | node`.

## Example

```lua
local position = getElementPosition(localPlayer)
local node, nodePosition = getClosestPathNode(position.x, position.y, position.z)
if node then
    setElementPosition(localPlayer, nodePosition.x, nodePosition.y, nodePosition.z + 1)
end
```

### Note

Only nodes in loaded path areas count: those near the player, or requested with `requestPathNodesInArea`.

## See also

- [getNthClosestPathNode (Shared)](https://wiki.mymp.gg/en/getNthClosestPathNode.md): Finds the nth road or footpath node closest to a point.
- [getPathNodesInRadius (Shared)](https://wiki.mymp.gg/en/getPathNodesInRadius.md): Lists the road or footpath nodes within a radius.
- [getPathNodeInfo (Shared)](https://wiki.mymp.gg/en/getPathNodeInfo.md): Returns what is known about a path node.
