# llGetLocalPos

*LSL function*

```lsl
vector vector llGetLocalPos();
```

- Returns: `vector`
- Energy: 10

If called from the root prim it returns the [position in the region](https://wiki.secondlife.com/wiki/Viewer_coordinate_frames#region) unless it is [attached](/functions/llGetAttached/) to which it returns the position relative to the [attach point](https://wiki.secondlife.com/wiki/Viewer_coordinate_frames#attachments).

Returns a [vector](https://wiki.secondlife.com/wiki/vector) that is the position relative ([local](https://wiki.secondlife.com/wiki/Viewer_coordinate_frames#local)) to the root.

```lsl title="How to use" frame="terminal"
vector result = llGetLocalPos();
```

## Examples

<details open>
<summary>Example 1</summary>

```lsl
default
{
    touch_start(integer vIntTouched)
    {
        string vStrMessage = "The touched prim is ";
        if (llDetectedLinkNumber(0) > 1)
        {
            vStrMessage += (string)llVecMag(llGetLocalPos()) + "m from ";
        }
        llSay(0, vStrMessage + "the root prim");
    }
}
```

</details>

## Helper functions

There is no function to set the position of a prim local to itself.

To set the position of a prim local to itself you would have to do something like:

```lsl
SetPositionLocalToCurrentPosition(vector local_position)
{
    llSetPos(llGetLocalPos() + (local_position * llGetLocalRot()));
}
```

Or:

```lsl
SetPositionLocalToCurrentPosition(vector local_position)
{
    llSetPos(llGetPos() + (local_position * llGetRot()));
}
```

## See also

### Functions

- [llGetRootPosition](/functions/llGetRootPosition/) — Gets the root prims global position
- [llGetPos](/functions/llGetPos/) — Gets the prims global position
- [llSetPos](/functions/llSetPos/) — Sets the prims global position

---

*Source: [LlGetLocalPos](https://wiki.secondlife.com/wiki/LlGetLocalPos) on the Second Life Wiki. Content from the Second Life Wiki article LlGetLocalPos (revision 1216731, 2024-05-27), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llGetLocalPos/
