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

Is it possible to create table dictionaries with more then one response?

For example

hi = {

["sup"] = "100","300"

}

Would it be possible to make it choose between the first and second of the ones listed, for example how would I make it so the 300 prints and how would I make it so the 100 prints. Assuming this is possible.

2 answers

You simply put a table in a table. If you want to index at random you can use the Random type to generate random index.

local outer = {
	["inner"] = {"100", "300"}
}

print(outer["inner"][1])
print(outer["inner"][2])

This is what I usually do to solve this dilemma.

local Foo = {
	Bar = {"100", "300"},
	Baz = {math.sqrt(-1)^2}
}

print(Foo.Bar[1]) -- 100
print(Foo.Baz[1]) -- should be -1, but may be -nan(ind)

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