<p>The error message is telling you that you've got a stray bracket, so count your brackets and see if the <code>(</code>s match the <code>)</code>s. Spoiler alert: they don't.</p>

<p>I can see two cases: after each <code>linear</code> function call you have a closing bracket after the <code>"Null 1"</code> string that isn't matched by an opening bracket. And <code>"Null 1"</code> on its own is just treated as a string, not a layer, so that's another problem.</p>

<p>I'm assuming you mean <code>thisComp.layer("Null 1")</code> which is a reference to a layer. So</p>

<pre><code>out = linear("Null 1").effect("Slider Control")("Slider"), 0, 100, 0, 2.5);
</code></pre>

<p>should be </p>

<pre><code>out = linear(thisComp.layer("Null 1").effect("Slider Control")("Slider"), 0, 100, 0, 2.5);
</code></pre>

CC BY-SA 4.0
2020-02-03T08:00:25.040Z
I got it working, thank you!
torako
CC BY-SA 4.0
2020-03-04T05:26:37.047Z
Don't thank me, mash that tick button!
stib
CC BY-SA 4.0
2020-02-03T03:57:44.703Z
2020-02-03T03:57:44.703Z
stib
<p>I'm trying to make a slider that basically can act as a crossfader between a bunch of different layers (so as the slider goes up, it fades through several layers). This is what I've written, and I'm getting the error "Error: SyntaxError: Unexpected Token )" on the first line and I'm having trouble telling where the problem is.
My code:</p>

<pre><code>if(thisComp.layer("Null 1").effect("Slider Control")("Slider") &lt;= 5)
{
    if(thisComp.layer("Null 1").effect("Slider Control")("Slider") &lt;= 2.5)
    {
        out = linear("Null 1").effect("Slider Control")("Slider"), 0, 100, 0, 2.5);
    }
    else
    {
        out = linear("Null 1").effect("Slider Control")("Slider"), 0, 100, 2.5, 5);
        out = 100 - out;
    }
    }
}
else{
    out = 0;
}
out;
</code></pre>

<p>Thank you!!</p>

<after-effects-expressions>
after effects slider control code help
torako
# after effects slider control code help

(Asked by: username_0 on 2020-02-01)

I'm trying to make a slider that basically can act as a crossfader between a bunch of different layers (so as the slider goes up, it fades through several layers). This is what I've written, and I'm getting the error "Error: SyntaxError: Unexpected Token )" on the first line and I'm having trouble telling where the problem is.
My code:
if(thisComp.layer("Null 1").effect("Slider Control")("Slider") <= 5)
{
    if(thisComp.layer("Null 1").effect("Slider Control")("Slider") <= 2.5)
    {
        out = linear("Null 1").effect("Slider Control")("Slider"), 0, 100, 0, 2.5);
    }
    else
    {
        out = linear("Null 1").effect("Slider Control")("Slider"), 0, 100, 2.5, 5);
        out = 100 - out;
    }
    }
}
else{
    out = 0;
}
out;

Thank you!!

**Tags:** after-effects-expressions


---

## 1 answers

### Answer by username_1 on 2020-02-03. Score: 1

The error message is telling you that you've got a stray bracket, so count your brackets and see if the (s match the )s. Spoiler alert: they don't.
I can see two cases: after each linear function call you have a closing bracket after the "Null 1" string that isn't matched by an opening bracket. And "Null 1" on its own is just treated as a string, not a layer, so that's another problem.
I'm assuming you mean thisComp.layer("Null 1") which is a reference to a layer. So
out = linear("Null 1").effect("Slider Control")("Slider"), 0, 100, 0, 2.5);

should be 
out = linear(thisComp.layer("Null 1").effect("Slider Control")("Slider"), 0, 100, 0, 2.5);

> **Comments:**
> **username_0**: I got it working, thank you!  
> **username_1**: Don't thank me, mash that tick button!  

---

