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

How to make a list with local function?

So I was watching a tutorial and they implemented a list. So I did the same and I got an error. I think the vid was a bit old, so can someone tell me what is wrong with it?

The Numbers are still grey in my Roblox Studio script

local codelist = (
	code1 = "WizWizGang",
	code2 = "UrMomGayBuddy",
	code3 = "GoCommitSmile",
	code4 = "IGotAnF",
	code5 = "TacoTuesdayBois"
)

The error is " Expected ')' (to close '(' at line 1), got '=' "

2 answers

You create a table or array with squiggly braces, { }.

local table = {}

You could then index the table when you define it using squared brackets, [ ].

local table = {"Apple", "Jeans"}

print(table[1]) --Index the first
--> Apple

Your case is using a dictionary so you could have it as:

local codelist = {
    code1 = "WizWizGang",
    code2 = "UrMomGayBuddy",
    code3 = "GoCommitSmile",
    code4 = "IGotAnF",
    code5 = "TacoTuesdayBois"
}

print(codelist.code1)
--> WizWizGang

--or

print(codelist["code1"])
--> WizWizGang

The two indexing methods above are syntactic or "code sugar" used when indexing.

If you need anything explained then let me know. You can also read more on Tables here:

###Tables

the answer above is pretty good but u can also do this

local dictionary = {
    [1] = "WizWizGang";
    [2] = "UrMomGayBuddy";
    [3] = "GoCommitSmile";
    [4] = "IGotAnF";
    [5] = "TacoTuesdayBois"
}
print(dictionary[1])
print(dictionary[2])
print(dictionary[3])
print(dictionary[4])
print(dictionary[5])

basically makes a dictionary and is pretty neat

self explanatory by the looks of it

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