Making a list/table variable in Lua

Status
Not open for further replies.

HitCoder

Launcher Blaster
Okay so I did this

yg7uyf76f7ghuigh87tg897.PNG

and it returns false meaning that the Lua script following isn't read.

What have I done wrong? is it how I initialized the variable?

Thanks again

HitCoder
 
You can't use a table as the source in a for ... in ... loop. You have to use an iterator. The best way to get an iterator from a table is to use pairs(table) or ipairs(table). (The difference is the latter only gets sequential keys from the table, while the former gets all keys.) Something like for key, skin in pairs(chars) will get you the desired outcome in your particular script. (You can name key something else if you'd rather. You could also just call it _ to signify it's unused; it's a sort of best practice with those kinds of loops. for _, skin in pairs(chars))
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top