# llGetPermissionsKey

*LSL function*

```lsl
key key llGetPermissionsKey();
```

- Returns: `key`
- Energy: 10

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.

Returns [NULL_KEY](/constants/NULL_KEY/) if permissions were neither granted nor declined (e.g., the permissions dialog was cancelled or otherwise ignored).

```lsl title="How to use" frame="terminal"
key result = llGetPermissionsKey();
```

## Examples

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

```lsl collapse={1-6, 14-25, 31-46}
// 1. rez a cube
// 2. create a new script and paste this
// 3. save script
// 4. right-click the prim and choose attach
// 5. touch the prim

announce_permissions_key()
{
    key permissionsKey = llGetPermissionsKey();

    llSay(0, "key llGetPermissionsKey() = '" + (string)permissionsKey + "'");
}

default
{
    state_entry()
    {
        announce_permissions_key();

        key owner = llGetOwner();
        llRequestPermissions(owner, PERMISSION_ATTACH);
    }

    touch_start(integer num_detected)
    {
        key id = llDetectedKey(0);
        key owner = llGetOwner();
        key permissionsKey = llGetPermissionsKey();

        if (id == owner)
        {
            if (permissionsKey == owner)
                llDetachFromAvatar();
            else
                llSay(0, "Can't detach from you, you have not granted ATTACH perms.");
        }
        else
            llSay(0, "Sorry, you're not the owner!");
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_ATTACH)
            announce_permissions_key();
    }
}
```

</details>

## Known issues

- [SVC-4862](https://jira.secondlife.com/browse/SVC-4862): [llGetPermissionsKey](/functions/llGetPermissionsKey/)() doesn't return [NULL_KEY](/constants/NULL_KEY/) when [permissions](https://wiki.secondlife.com/wiki/Category:LSL_Permissions/Script) are declined

## See also

### Functions

- [llGetPermissions](/functions/llGetPermissions/)
- [llRequestPermissions](/functions/llRequestPermissions/)

### Events

- [run_time_permissions](/events/run_time_permissions/)

---

*Source: [LlGetPermissionsKey](https://wiki.secondlife.com/wiki/LlGetPermissionsKey) on the Second Life Wiki. Content from the Second Life Wiki article LlGetPermissionsKey (revision 1197588, 2015-09-23), CC BY-SA 3.0.*

---

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