Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Getting variables with variables?

So for example I have this:

local coolthing = lololol
local what = cool

And I want it to print "lololol", but lets say I don't know that thing has cool before it's name all I know is "what" and that the variable with "lololol" ends with "thing" I tryed this:

 print(what.."thing")

but it didn't work, it prints "coolthing", not "lololol"... :c

1 answer

✓ Accepted answer

Yes.

local str = "Hi"
local a = str
print(a) --> Hi

This is perfectly valid.


In your code, you may have copied it incorrectly because

local what = cool
print(what.."thing")

won't print coolthing, but will error because the cool you set the variable to doesn't exist.


Moreover, putting the variable name in a string also won't work (ex: print("a")) because a string is merely a collection of characters and contains no other information.

This discussion is preserved as it was. New answers, comments, and votes are closed.