# llGetRootRotation

*LSL function*

```lsl
rotation rotation llGetRootRotation();
```

- Returns: `rotation`
- Energy: 10

Returns a rotation representing the orientation (relative to the region) of the root prim of the linkset containing the script.

Returns a [rotation](https://wiki.secondlife.com/wiki/rotation) that is the [region](https://wiki.secondlife.com/wiki/Viewer_coordinate_frames#region) rotation of the root prim of the [object](https://wiki.secondlife.com/wiki/Object).

```lsl title="How to use" frame="terminal"
rotation result = llGetRootRotation();
```

## Caveats

- Returns an accurate facing for Avatars seated or in mouselook, but only a rough direction otherwise when called from an attached prim.
- When a seated avatar is in mouselook, its rotation is affected by the camera's rotation. There is no way to get the actual rotation of an avatar while seated in mouselook.
- This function incorrectly (but usefully) returns the avatars region rotation when called in an attachment, use the following instead:

```lsl
//  if called only from the root
    llGetLocalRot();
//  if called from in a linked object
    llList2Rot( llGetLinkPrimitiveParams( LINK_ROOT, [PRIM_ROT_LOCAL] ), 0 );
//  this alternative works correctly in all scenarios
    llList2Rot( llGetLinkPrimitiveParams( !!llGetLinkNumber(), [PRIM_ROT_LOCAL] ), 0 );
```

## Examples

<details open>
<summary>Simple example to set region rotation of child prim in unattached link set</summary>

```lsl
default
{
  state_entry()
  {
    //Rotate 45 degrees about Y-axis
    rotation globalRot = llEuler2Rot(<0.0, 45.0, 0.0> * DEG_TO_RAD);
    llSetLocalRot(globalRot / llGetRootRotation());
  }
}
```

</details>

## Notes

In an attached object, returns region rotation of avatar NOT of the object's root prim. See [special cases of rotation](https://wiki.secondlife.com/wiki/Rotation#single-or-root-prims-vs-linked-prims-vs-attachments).

## Known issues

- [VWR-1331](https://jira.secondlife.com/browse/VWR-1331): Improve accuracy of avatar's visible rotation

## See also

### Functions

- [llGetRot](/functions/llGetRot/)
- [llGetLocalRot](/functions/llGetLocalRot/)
- [llGetPrimitiveParams](/functions/llGetPrimitiveParams/)
- [llGetLinkPrimitiveParams](/functions/llGetLinkPrimitiveParams/)

---

*Source: [LlGetRootRotation](https://wiki.secondlife.com/wiki/LlGetRootRotation) on the Second Life Wiki. Content from the Second Life Wiki article LlGetRootRotation (revision 1194251, 2015-01-22), CC BY-SA 3.0.*

---

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