New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

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

Asked by 3 months 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 3 months 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