Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Adding a key to a table?

Asked by 8 years ago

When you add something to a table, you usually add a value, right? But what if I wanted to add a key to that value when I add it to a table? Is this possible and if so how do I do it?

0
For example table = {['index'] = value} lightninja212 25 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

This is how you do it:

local table = {}

table["Zombie"] = "I eat brainz"

The first part is simply indexing the key that you want to index. It creates a new value if the key does not exist. Then it sets the following value to be it's value.

Ad

Answer this question