A quick question, why is there an error?

So I just have a quick question. Why is the first “[” underlined in red? Like what error is there?

Roles = ["Explorer", "Guard", "Spy"]

Sorry because it won’t show it here, because when I try and take a screenshot it goes away.

The syntax. In lua you create arrays using { and }, like this:

local Roles = {"Explorer", "Guard", "Spy"}
2 Likes

Thank you! But then what are “[]” used for?

They are used to reference elements of arrays or dictionaries. For example,

Roles[1] = "Explorer"
Roles[2] = "Gaurd"
.
.
.

And you can do this with any type of key if you use a dictionary,

Roles["How are you today"] = "Not bad not bad"

Lots of flexibility.

2 Likes