• Trying to set a variable with a concatenated name
    4 replies, posted
I'm trying to set the value of a variable with a concatenated name but I get this error [ERROR] lua/autorun/server/data.lua:44: '<name>' expected near '"data"'   1. unknown - lua/autorun/server/data.lua:0 this is how I did it local "data"..DataPosition = data When I got this error DataPosition was set to 3 and data to a string (a JOJO reference, I believe )
You can't dynamically define variable names like that. You'll have to use a table.
Ok, I didn't know that it wasn't possible :/
You can make global variables like that by _G["data"..DataPosition] = data
Keep in mind that just like using global variables, this is in 99% of cases a terrible idea.
Sorry, you need to Log In to post a reply to this thread.