Using a
1 | local chars = items:GetChildren() |
2 | for i = 1 , #chars do |
How would I make it create a new value with the name being the number of the "i"?
You could use the _G
function to accomplish that.
1 | local chars = items:GetChildren() |
2 | for i,v in pairs (chars) do |
3 | _G [ "Item" .. i ] = "foobar" |
4 | end |
I also changed the for loop so it's a bit better (i would say). You can use v to reference the object that has been indexed by the i value, basically the object is chars[i].
You can then use this little bit of code to reference that value.
1 | print (_G [ "Item" .. 1 ] ) |
output:
foobar
The _G
function is global so all scripts can access it.