title: Gmod Lua - Checking if flag exists in bitflag
body: <p>I am trying to check if a key is being pressed at the current frame in Gmod Lua with <a href="http://wiki.garrysmod.com/page/CUserCmd/GetButtons" rel="nofollow noreferrer"><code>cmd:GetButtons()</code></a>.</p>
  
  <p>In other words, I am trying to see if a flag exists in a bitflag in Lua.</p>
  
  <hr>
  
  <p><strong>I am attempting the <a href="https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexad35.html" rel="nofollow noreferrer">following code</a>:</strong></p>
  
  <pre><code>-- flags = 1024 (when holding forward)
  -- IN_FORWARD = 1024
  local flags = cmd:GetButtons()
  if (flags &amp; IN_FORWARD) == IN_FORWARD then
      print("You're walking forward.")
  end
  </code></pre>
  
  <p><strong>And receiving the following error in my console:</strong></p>
  
  <pre><code>')' expected near '&amp;'
  </code></pre>
  
  <hr>
  
  <p>Does lua not support the logical operator <strong><code>&amp;</code></strong>?</p>
  
  <p>Is there an alertnative way to check if a flag exists in a bitflag using Lua?</p>