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

what is "[i]" and "[[i]]" Used for?

I have seen it only in Person299's admin commands but I have Absolutely No Idea how it is used Any help would be much appreciated!

1 answer

✓ Accepted answer

In a table, you can take the table's name followed by brackets and a number, and that gives you the value corresponding to the number, like this:

MyTable = {"Hi","People","I'm","Perci1!"}
print(MyTable[1])
print(MyTable[3])

--output: Hi, I'm

If you have a variable for a number and that variable is changing, like in a for loop, then you can affect every value in a table in a very short amount of time.

MyTable = {"Hi","People","I'm","Perci1!"}

for i = 1,#MyTable do --#MyTable is the amount of values in the table. In this case, 4.
	print(MyTable[i]) --Since i changes each time, we will print all the values in the table one at a time.
end

--output: Hi, People, I'm, Perci1!

2 comments

0

THANKS :D

0

No problem c:

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