3rd time editing this since it's not 'clear enough'... HOW... DO... YOU... CONVERT... A... STRING... TO... A... FORM... THAT... IT... CAN... BE... USED... AS... A... VARIABLE...
local table = { one = "wasupe" } table[one] = 100
Posting it in case your mind cannot comprehend my writing
local tab = {1, 2, 3, "Stupid", "Next"}; for i = 1, #tab -1 do local current = tab[i]; if (type(current) == "string") then local nextVal = tab[i + 1]; end end
--Revoked Code
From my understanding, there is no way to "name" actual variable like that. My example show above, it isn't a variable to begin with. So, I don't know.
Long story short, you are doing something that you wouldn't even need to do. Post your scenario. Why do you need to do this. Then maybe we can help you with an alternative.
Another Edit.
If you wanted user to type in like Tab[Money] in chat and want to return the money's value, you could do this.
local var = { -- Container for all the "Chat Methods" Tab = { -- "Tab will be the Table that will hold the properties Money = 100; -- If you wanted more, you can simply add more. Like Age = 2; }, Give = { AddMoney = 100; } -- And so on.... } local input = io.read("*line"); -- If you are doing in ROBLOX, there isn't io. But you can get the message from the chat. I won't do that here. Too lazy. local function decode (input) local p1 = input:find("%["); -- Find the First occurrence of [ local prefix = input:sub(1, p1 -1); -- Will be the container you want to go into. local nxt = input:sub(p1 + 1, #input - 1); -- Will be the field's value you want to fetch print(prefix, nxt) return var[prefix][nxt] -- Returns the fields value. end; print(decode(input));
if you type Tab[Money]
it will go into Var and find Tab.
Then it will find the Money
and return its value.
You can probably make it better. But this is the gist of it. Good luck, whatever you are doing.