# Lua "arg" variable not working (SOLVED)

**URL:** <https://forum.defold.com/t/lua-arg-variable-not-working-solved/22271>\
**Category:** Bugs\
**Created:** [June 15, 2018, 8:05pm UTC](https://forum.defold.com/t/lua-arg-variable-not-working-solved/22271 "2018-06-15T20:05:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 15, 2018, 8:21pm UTC](https://forum.defold.com/t/lua-arg-variable-not-working-solved/22271/2 "2018-06-15T20:21:12Z")

</div>

We use LuaJIT for all platforms but iOS 64 and HTML5. The [LuaJIT FAQ](http://luajit.org/faq.html) reads:

“Q: Why do I get this error: “attempt to index global ‘arg’ (a nil value)”?  
Q: My vararg functions fail after switching to LuaJIT!  
LuaJIT is compatible to the Lua 5.1 language standard. It doesn’t support the implicit arg parameter for old-style vararg functions from Lua 5.0.  
Please convert your code to the Lua 5.1 vararg syntax.”

You can get the arguments in two ways:

```
function foo(...)
   local args = {...}
   print(args[1])
   print(select(1, ...))
end

```

---

_[View the full topic](https://forum.defold.com/t/lua-arg-variable-not-working-solved/22271)._
