# llStartAnimation

*LSL function*

```lsl
void llStartAnimation(string anim);
```

- `string anim`: Name of the animation in the prim's inventory, or the built-in animation name.

- Energy: 10
- Permission: `PERMISSION_TRIGGER_ANIMATION`

Starts the animation anim (inventory or built-in) on the avatar who granted the script the PERMISSION_TRIGGER_ANIMATION permission (automatically granted for attached or sat-on objects).

Start animation **anim** for agent that granted [PERMISSION_TRIGGER_ANIMATION](/constants/PERMISSION_TRIGGER_ANIMATION/) if the permission has not been revoked.

```lsl title="How to use" frame="terminal"
llStartAnimation("");
```

## Caveats

- Only 30 animations can be played at a time. (Prior to 1.25.4 the limit was 15 and prior to 1.25.3 there was no limit at all.)

## Examples

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

```lsl collapse={1-8, 14-21}
default
{
    touch_start(integer detected)
    {
        llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
    }
    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            llStartAnimation("sit");
            llOwnerSay("animation will end in 5 seconds");
            llSetTimerEvent(5.0);
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llStopAnimation("sit");
    }
}
```

</details>

<details>
<summary>Add an animation or pose inside the same object as this script:</summary>

```lsl collapse={1-33}
string animation; // the first animation in inventory will automatically be used
  // the animation name must be stored globally to be able to stop the animation when standing up

default
{
    state_entry()
    {
        // set sit target, otherwise this will not work
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
    }

    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            key av = llAvatarOnSitTarget();
            if (av) //evaluated as true if not NULL_KEY or invalid
                llRequestPermissions(av, PERMISSION_TRIGGER_ANIMATION);
            else // avatar is standing up
            {
                if (animation)
                    llStopAnimation(animation); // stop the started animation
                llResetScript(); // release the avatar animation permissions
            }
        }
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            animation = llGetInventoryName(INVENTORY_ANIMATION,0); // get the first animation from inventory
            if (animation)
            {
                llStopAnimation("sit"); // stop the default sit animation
                llStartAnimation(animation);
            }
        }
    }
}
```

</details>

<details>
<summary>Common script to play some kind of a "holding animation" while an object is attached to an avatar:</summary>

```lsl collapse={1-23}
string animation_name = "hold";

default
{
    // Whenever this object is attached or detached...
    attach(key id)
    {
        if (id)
        {   // If it was just attached, request permission to animate.
            llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        }
        else
        {   // It's being detached...
            if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
            {   // If we have permission to animate, stop the animation.
                llStopAnimation(animation_name);
            }
        }
    }

    // Whenever permissions change...
    run_time_permissions(integer permissions)
    {
        if (permissions & PERMISSION_TRIGGER_ANIMATION)
        {   // If permission to animate was granted, start the animation.
            llStartAnimation(animation_name);
        }
    }
}
```

</details>

## Known issues

From the issue templates included by the wiki article:

- BUG-7729 (nf): **llStartAnimationSynced**() - synchronised animation support

The wiki article also includes shared templates whose conditional content is not reproduced here: [Template:Issues/BUG-10971](https://wiki.secondlife.com/wiki/Template:Issues/BUG-10971), [Template:Issues/BUG-7853](https://wiki.secondlife.com/wiki/Template:Issues/BUG-7853).

## See also

### Functions

- [llStopAnimation](/functions/llStopAnimation/)

### Articles

- [Internal_Animations](https://wiki.secondlife.com/wiki/Internal_Animations) — lists internal Animations always available

---

*Source: [LlStartAnimation](https://wiki.secondlife.com/wiki/LlStartAnimation) on the Second Life Wiki. Content from the Second Life Wiki articles LlStartAnimation (revision 1209560, 2020-09-22), Template:Issues/BUG-10971 (revision 1198291, 2015-12-16), Template:Issues/BUG-7729 (revision 1198281, 2015-12-16), Template:Issues/BUG-7853 (revision 1198290, 2015-12-16), Template:LSL Function/permission (revision 1200093, 2016-05-12) and Template:LSL Function/inventory (revision 1191151, 2014-06-07), CC BY-SA 3.0.*

---

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