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

How can I make this loop depending on howw many values there are?

This is my script, I don't know how to make it loop for as many values as there are in the table, pls help!!!

local TBL = {23, 34, 23, 123, 54, 23, 5432}

for i = 1,7 do
	print(TBL[i])
end

1 answer

✓ Accepted answer

You need to use this operator: # it does exactly want you want to do, say I had a table like this: local Numbers = {23, 545, 235, 4543, 343343,2434,34343,43434343} and I wanted to know how many values there are in Numbers, I would go like this #Numbers and that would return a number, this can also be used in strings, it counts all the characters and returns a number of characters, like this: local Line = "Hi. my name is SuperSamyGamer and I code" print(#Line)

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