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

How Can I Index Numbers In A Table?

I'm storing numbers in a table like this:

local table = {231, 5353, 2867}

I'd like to know if there's a possible way to index those values like this:

table[5353]

I thought about changing the table format to {[231] = true} however that method won't work with JSONEncode. If anyone knows a possible solution, please let me know.

Also, i'm trying to avoid having to loop through the table just to make things easier.

1 answer

In the Lua language, [] is not used to index table values. The second script bar would represent the 5,353rd value in the "table" table.

2 comments

0

Is there any possible way to check if there's a value in the table without looping?

0

you could check for specific slots in the table, although it is not suggested

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