# Permissions

> lsl.dev (unofficial LSL docs). Full API: https://lsl.dev/api.json · Index for LLMs: https://lsl.dev/llms.txt

> Runtime permissions: asking an avatar to let a script animate, control, attach, teleport or pay on its behalf.

Some things a script can do affect an avatar directly: animating it, taking its controls, moving its camera, attaching to it, teleporting it or spending its owner's money. Before a script may do any of these, an avatar has to grant it the matching runtime permission. These are separate from the [permission masks](/features/inventory/) on inventory items, which control copying, modifying and transferring.

A script asks with [`llRequestPermissions`](/functions/llRequestPermissions/), and the answer arrives in the [`run_time_permissions`](/events/run_time_permissions/) event. Each permission is a bit in a [script permission](/constants/groups/ScriptPermission/) mask.

## Concepts

- Permissions are flags combined with `|` and requested together in one call
  - A script holds permissions from one avatar at a time; a new request replaces the previous grant
  - [`llGetPermissions`](/functions/llGetPermissions/) returns the granted mask and [`llGetPermissionsKey`](/functions/llGetPermissionsKey/) the avatar who granted it
- The avatar sees a dialog and can accept or decline
  - Declining fires [`run_time_permissions`](/events/run_time_permissions/) with the declined bits missing, so always check the mask
  - Some permissions are granted without a dialog when the avatar is sitting on or wearing the object, such as [`PERMISSION_TAKE_CONTROLS`](/constants/PERMISSION_TAKE_CONTROLS/), [`PERMISSION_TRIGGER_ANIMATION`](/constants/PERMISSION_TRIGGER_ANIMATION/) and the camera permissions
- Some permissions can only be granted by the object's owner, such as [`PERMISSION_DEBIT`](/constants/PERMISSION_DEBIT/), [`PERMISSION_CHANGE_LINKS`](/constants/PERMISSION_CHANGE_LINKS/) and [`PERMISSION_ATTACH`](/constants/PERMISSION_ATTACH/)
- Calling a function without its permission fails with a script error instead of acting
- Grants survive state changes but are cleared when the script resets
  - [`PERMISSION_CONTROL_CAMERA`](/constants/PERMISSION_CONTROL_CAMERA/) is revoked when the avatar stands up or detaches
- [Experiences](/features/experience/) use [`llRequestExperiencePermissions`](/functions/llRequestExperiencePermissions/) instead: an avatar accepts the experience once and later requests are granted silently

## Functions and events

These are the functions and events for requesting and checking permissions.

- `void` [`llRequestPermissions`](/functions/llRequestPermissions/) `(key agent, integer permissions)`
- `event` [`run_time_permissions`](/events/run_time_permissions/) `(integer perm)`
- `integer` [`llGetPermissions`](/functions/llGetPermissions/) `()`
- `key` [`llGetPermissionsKey`](/functions/llGetPermissionsKey/) `()`
- `void` [`llRequestExperiencePermissions`](/functions/llRequestExperiencePermissions/) `(key agent, string name)`
- `event` [`experience_permissions`](/events/experience_permissions/) `(key agent_id)`
- `event` [`experience_permissions_denied`](/events/experience_permissions_denied/) `(key agent_id, integer reason)`

## Requesting permissions

Request in response to the avatar, from [`touch_start`](/events/touch_start/), [`attach`](/events/attach/) or a sit in [`changed`](/events/changed/), and act once the grant arrives:

```lsl
default
{
    touch_start(integer total_number)
    {
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
            llStartAnimation("dance1");
    }
}
```

## Permissions

| Permission | Value | Allows | Granted by |
| --- | --- | --- | --- |
| [`PERMISSION_DEBIT`](/constants/PERMISSION_DEBIT/) | `0x2` | Paying out L$ with [`llGiveMoney`](/functions/llGiveMoney/) and [`llTransferLindenDollars`](/functions/llTransferLindenDollars/) | Owner |
| [`PERMISSION_TAKE_CONTROLS`](/constants/PERMISSION_TAKE_CONTROLS/) | `0x4` | Capturing movement keys with [`llTakeControls`](/functions/llTakeControls/) | Any avatar |
| [`PERMISSION_TRIGGER_ANIMATION`](/constants/PERMISSION_TRIGGER_ANIMATION/) | `0x10` | [Starting](/functions/llStartAnimation/) and [stopping](/functions/llStopAnimation/) animations | Any avatar |
| [`PERMISSION_ATTACH`](/constants/PERMISSION_ATTACH/) | `0x20` | [Attaching](/functions/llAttachToAvatar/) and [detaching](/functions/llDetachFromAvatar/) the object | Owner |
| [`PERMISSION_CHANGE_LINKS`](/constants/PERMISSION_CHANGE_LINKS/) | `0x80` | [Linking](/functions/llCreateLink/) and [unlinking](/functions/llBreakLink/) prims | Owner |
| [`PERMISSION_TRACK_CAMERA`](/constants/PERMISSION_TRACK_CAMERA/) | `0x400` | Reading the camera [position](/functions/llGetCameraPos/) and [rotation](/functions/llGetCameraRot/) | Any avatar |
| [`PERMISSION_CONTROL_CAMERA`](/constants/PERMISSION_CONTROL_CAMERA/) | `0x800` | [Setting](/functions/llSetCameraParams/) and [clearing](/functions/llClearCameraParams/) camera parameters | Sitting or wearing avatar |
| [`PERMISSION_TELEPORT`](/constants/PERMISSION_TELEPORT/) | `0x1000` | Teleporting with [`llTeleportAgent`](/functions/llTeleportAgent/) | Any avatar |
| [`PERMISSION_SILENT_ESTATE_MANAGEMENT`](/constants/PERMISSION_SILENT_ESTATE_MANAGEMENT/) | `0x4000` | Changing estate access with [`llManageEstateAccess`](/functions/llManageEstateAccess/) | Owner |
| [`PERMISSION_OVERRIDE_ANIMATIONS`](/constants/PERMISSION_OVERRIDE_ANIMATIONS/) | `0x8000` | [Replacing default animations](/functions/llSetAnimationOverride/) | Any avatar |
| [`PERMISSION_RETURN_OBJECTS`](/constants/PERMISSION_RETURN_OBJECTS/) | `0x10000` | Returning objects [by key](/functions/llReturnObjectsByID/) or [by owner](/functions/llReturnObjectsByOwner/) | Owner |
| [`PERMISSION_PRIVILEGED_LAND_ACCESS`](/constants/PERMISSION_PRIVILEGED_LAND_ACCESS/) | `0x80000` | Selling parcels with [`llSetParcelForSale`](/functions/llSetParcelForSale/) | Owner |
| [`PERMISSION_GAME_CONTROL`](/constants/PERMISSION_GAME_CONTROL/) | `0x100000` | Receiving [game control input](/features/input/game-control/) | Any avatar |

## Scripting Details

Here are the functions and events in detail.

- `void` [`llRequestPermissions`](/functions/llRequestPermissions/) `(key agent, integer permissions)`: Requests permissions (a bitfield specified by permissions) from the agent in the same region, calling run_time_permissions if granted. This call does not pause script execution.
- `event` [`run_time_permissions`](/events/run_time_permissions/) `(integer perm)`: Triggered when an agent grants or denies runtime permissions requested by llRequestPermissions. Passes the active integer permissions bitfield perm (returns 0 if no permissions are currently granted).
- `integer` [`llGetPermissions`](/functions/llGetPermissions/) `()`: Returns an integer bitfield representing the permissions (PERMISSION_*) currently granted to the script.
- `key` [`llGetPermissionsKey`](/functions/llGetPermissionsKey/) `()`: Returns the key (UUID) of the avatar that last granted or declined permissions to the script, or NULL_KEY if the permissions request was ignored or cancelled.
- `void` [`llRequestExperiencePermissions`](/functions/llRequestExperiencePermissions/) `(key agent, string name)`: Requests permission from the specified agent to participate in the experience. These permissions are persistent and apply grid-wide across all scripts in the experience, automatically triggering experience_permissions or experience_permissions_denied.
- `event` [`experience_permissions`](/events/experience_permissions/) `(key agent_id)`: Triggered when the agent specified by agent_id approves an experience permissions request (interactively or automatically if previously approved).
- `event` [`experience_permissions_denied`](/events/experience_permissions_denied/) `(key agent_id, integer reason)`: Triggered when the agent specified by agent_id denies experience permissions, or when permission is blocked for other reasons (specified by the error code reason).

Constant groups: [ScriptPermission](/constants/groups/ScriptPermission/) (13)

## Related

See also: [Experience](/features/experience/), [Money](/features/money/), [Input](/features/input/), [Avatars](/features/avatar/), [Camera](/features/camera/), [Permissions](/categories/permissions/)
   (planned: Recipe: animation and control HUD)

## Related features

- [Experience](/features/experience/)
- [Money](/features/money/)
- [Input](/features/input/)
- [Avatars](/features/avatar/)
- [Camera](/features/camera/)

## Categories

- [Permissions](/categories/permissions/)

---

From lsl.dev: https://lsl.dev/features/permissions/
