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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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)

Ad

Answer this question