Answers.Body: <p>I'm not that experienced with expression, so maybe I'm understanding something wrong, but both your code and the code of @stib's answer give me clear error messages. <code>marker.comment</code> is not a function and above that, the code has several more issues.</p>
  <p>Using part of the code from <a href="https://ae-expressions.docsforadobe.dev/examples.html?highlight=marker#animate-scale-at-each-layer-marker" rel="nofollow noreferrer">this reference</a> I got the following working:</p>
  <pre><code>n = 0;
  t = 0;
  if (marker.numKeys &gt; 0)
  {
       n = marker.nearestKey(time).index;
       if (marker.key(n).time &gt; time)
          n--;
  }
  if (n &gt; 0 )
      t = time - marker.key(n).time;
  
  if(t&gt;0 &amp;&amp; marker.key(n).comment==&quot;R1 L1&quot;)
      40;
  else
      value;
  </code></pre>
  <p>I've created a simple shape and applied the expression for example to the opacity property (100% at start) and added a marker with the comment &quot;R1 L1&quot; and as soon as the playhead passes this marker the opacity changes to 40%. I think this behaves as intended.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-27T14:11:07.003Z
Answers.LastActivityDate: 2021-02-06T23:09:05.280Z
Answers.LastEditDate: 2021-02-06T23:09:05.280Z
Answers.UserDisplayName: Matt
Answers.Body: <p>You need to check <a href="https://helpx.adobe.com/au/after-effects/user-guide.html/au/after-effects/using/expression-basics.ug.html" rel="nofollow noreferrer">how expressions work</a>. An expression sets the value of a property with the first line that returns a value. So for example an expression could just be:</p>
  <pre><code>40
  </code></pre>
  <p>since that line returns the value 40. The second line in your expression <code>value = 40</code> does not return a value, it attempts to set the <a href="https://ae-expressions.docsforadobe.dev/property.html#value" rel="nofollow noreferrer"><code>value</code> property</a> to 40, which doesn't work, because <code>value</code> is read-only.</p>
  <p>What you need to do is return <code>40</code> if the time is after the marker, and if not return the current <code>value</code>, thus:</p>
  <pre><code>if (marker.comment(&quot;R1 L1&quot;).time &gt; time){
    40;
  } else {
    value;
  }
  </code></pre>
  <p>Or more tersely, using <a href="https://codeburst.io/javascript-the-conditional-ternary-operator-explained-cac7218beeff" rel="nofollow noreferrer">ternary</a> notation, which uses the form <code>(condition)? &lt;value if true&gt; : &lt;value if false&gt;</code>, thus:</p>
  <pre><code>(marker.comment(&quot;R1 L1&quot;).time &gt; time)? 40 : value
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-08T11:52:04.460Z
Answers.Text: “marker.comment” doesn't work, but “marker.key” does.
Answers.UserDisplayName: MG_
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-27T00:45:10.870Z
Answers.LastActivityDate: 2021-01-27T00:45:10.870Z
Answers.UserDisplayName: stib
Body: <p>I wanted to change one value when marker with certain comment starts. I've tried something like this, but it doesn't work.</p>
  <pre><code>if (marker.comment(&quot;R1 L1&quot;).time &gt; time){
    value = 40;
  }
  </code></pre>
  
Tags: <after-effects><after-effects-expressions>
Title: How to change value when passing marker with certain comment
UserDisplayName: mike
ThreadText: # How to change value when passing marker with certain comment
  
  (Asked by: username_0 on 2021-01-26)
  
  I wanted to change one value when marker with certain comment starts. I've tried something like this, but it doesn't work.
  
  ```
  if (marker.comment("R1 L1").time > time){
    value = 40;
  }
  
  ```
  
  **Tags:** after-effects, after-effects-expressions
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-01-27. Score: 0
  
  I'm not that experienced with expression, so maybe I'm understanding something wrong, but both your code and the code of @username_2's answer give me clear error messages. `marker.comment` is not a function and above that, the code has several more issues.
  
  Using part of the code from [this reference](https://ae-expressions.docsforadobe.dev/examples.html?highlight=marker#animate-scale-at-each-layer-marker) I got the following working:
  
  ```
  n = 0;
  t = 0;
  if (marker.numKeys > 0)
  {
       n = marker.nearestKey(time).index;
       if (marker.key(n).time > time)
          n--;
  }
  if (n > 0 )
      t = time - marker.key(n).time;
  
  if(t>0 && marker.key(n).comment=="R1 L1")
      40;
  else
      value;
  
  ```
  
  I've created a simple shape and applied the expression for example to the opacity property (100% at start) and added a marker with the comment "R1 L1" and as soon as the playhead passes this marker the opacity changes to 40%. I think this behaves as intended.
  
  
  ---
  
  ### Answer by username_2 on 2021-01-27. Score: 0
  
  You need to check [how expressions work](https://helpx.adobe.com/au/after-effects/user-guide.html/au/after-effects/using/expression-basics.ug.html). An expression sets the value of a property with the first line that returns a value. So for example an expression could just be:
  
  ```
  40
  
  ```
  
  since that line returns the value 40. The second line in your expression `value = 40` does not return a value, it attempts to set the [`value` property](https://ae-expressions.docsforadobe.dev/property.html#value) to 40, which doesn't work, because `value` is read-only.
  
  What you need to do is return `40` if the time is after the marker, and if not return the current `value`, thus:
  
  ```
  if (marker.comment("R1 L1").time > time){
    40;
  } else {
    value;
  }
  
  ```
  
  Or more tersely, using [ternary](https://codeburst.io/javascript-the-conditional-ternary-operator-explained-cac7218beeff) notation, which uses the form `(condition)? <value if true> : <value if false>`, thus:
  
  ```
  (marker.comment("R1 L1").time > time)? 40 : value
  
  ```
  
  > **Comments:**
  > **username_3**: “marker.comment” doesn't work, but “marker.key” does.  
  
  ---
  
  