To accomplish this, you're going to need to use a for loop. :P
Just a heads up: I'm not going to be re-writing (editing) your code, b/c it would feel like I did all the work for you; if someone did that w/ me, I wouldn't be happy... Buuuut also b/c it's super simple (once you get the hang of it). :P
First, lets set up a(n example) table:
local TableExample = {
'Value1',
Value2 = true,
[tostring('Value' .. 3)] = true,
'Value4'
}
Now that we got our table set up, lets begin the process (of explanations!) :D Onto... the magical for loops!! :O For this example, I'll be using a generic for loop:
for i, v in pairs(TableExample) do
print(i, v)
end
And, ta-da! There's our for loop! :D Now, when we fire the above code(s(?), the output will return the following:
Aaaaaaand wa-la! That's (an example of) how you use the generic for loop! :D
What the generic for does is returns the data(s) from the table, depending on how many items/ storage's there're. (Say you have 3 items in the table: the generic for, w/ pairs (or if you prefer, next)). (Ugh, I feel that that didn't explain it at all/ didn't represent the functions properly. ;-;) I forgot what the first value stands for, like in the generic for presented earlier w/ 'i, v', I do, however, know that the second value stands for the value at the current iteration (the generic for returns the value, and same w/ the first value as well).
Stuff touched on, but didn't go into great detail about
Tables - Stores data such as strings, numbers, characters, objects (children), and/ or information.
For Loops - There's a lot to cover, so if you wish to look up on it more, click on the highlighted For Loop sentence-starter before the explanation even begins. :)
The Generic For - Already explained, so this is optional. :P However, if you wish to research more, you can, like the last, click on the highlighted words. :)
Pairs Iterator - This is a tough one to explain, so please read the wiki document. ':)
Next Iteration - ^
Hope this helped you in any way! :D
2 comments
https://scriptinghelpers.org/blog/common-mistakes#GetChildren
thank you