There is, of course nothing wrong in the code you posted. However, it might act oddly in an interactive environment, depending on how chunks are collected and handed to the parser.
As written, you declare a local tempArray and then apparently use it. If those lines are typed into the interactive Lua prompt which takes each line as an individual chunk, then the local created in the first line will be created and discarded. The second line will create a global variable with the same name, and the third line will use the global to set a field. You can demonstrate this like this:
C:\Users\Ross>lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> local tempArray
> tempArray = {}
> tempArray["Some String"] = true
>
> table.foreach(tempArray,print)
Some String true
>
> print(type(_G.tempArray))
table
>
Here, I've demonstrated that the table tempArray exists and has exactly the one key with the value true. By printing the type of _G.tempArray I've demonstrated that a global variable was created.
By using a do ... end pair to force the interactive prompt to treat the whole block as a single chunk, we both create and use the local variable. Unfortunately after the end of the chunk, the local is now out of scope and can't be seen any more.
C:\Users\Ross>lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> do
>> local tempArray
>> tempArray = {}
>> tempArray["Some String"] = true
>> end
> print(type(_G.tempArray))
nil
> table.foreach(tempArray,print)
stdin:1: bad argument #1 to 'foreach' (table expected, got nil)
stack traceback:
[C]: in function 'foreach'
stdin:1: in main chunk
[C]: ?
>
I don't know enough about WoW to speak with authority, but it is likely that locals declared in a script may have interesting issues with visibility and value persistence. If they use a significant amount of sandboxing of scripts, even globals in a script may not be visible to other scripts.
localwill isolate that variable to that chunk (line) of input. But in your example,tempArraywould then be defined global on the next line.