title: How to fix this error: attempt to index a number value in Lua Script
body: <p>I'm learning Lua but I got this error attempt to index a number value when compiler reach this piece of code</p>
  <pre><code>if a() == -1 then
      return code
  end
  </code></pre>
  <p>Console Error</p>
  <p><a href="https://i.stack.imgur.com/i5BkS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i5BkS.png" alt="1" /></a></p>
  <p>i tried to change the type of return from number to boolean but i got the same error</p>
  <p>Boolean console error</p>
  <p><a href="https://i.stack.imgur.com/qkf6L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qkf6L.png" alt="2" /></a></p>
  <pre><code>function a()
      local message = developer:historicalMessage(22)
      if message == nil or message[1] == nil then return nil end
      message = message[1]
      if message.subs == 0 then
          global:printMessage(&quot;Here !&quot;)
          return -1
      end
  end
  
  function Notif()
      if a() == -1 then
          return code
      end
  end
  </code></pre>