I'm trying to use strings in a table to reference children of intvalues in a folder, however, it errors, saying things like "(arrayname) is not a valid member of Folder" and I've tried so far to do things like this (some code may seem strange):
local stats = game.Players.LocalPlayer:WaitForChild("LeaderStats") local Index = {"IntValue1", "IntValue2", "IntValue3", "IntValue4"} local priority = {4, 2, 3, 1} for i = 1, stats.SeperateValue.Value do for i = 1, #priority do if stats:WaitForChild(Index[priority[i]]).Value > 0 then --blah blah blah break end end end
Also, just as another small question, would the "break" end every single loop, or just the one for loop it's nested inside of?
How do we access something with dot notation?? Very simple You put the index that you want inside a variable inside the table
local stats = game.Players.LocalPlayer:WaitForChild("LeaderStats") local Index = { IntValue1 = stats.Stat1, -- or stats IntValue2= stats.Stat2, IntValue3 =stats.Stat3, IntValue4 = stats.Stat4 } local priority = {4, 2, 3, 1} for i = 1, stats.SeperateValue.Value do for i = 1, #priority do if stats:WaitForChild(Index[priority[i]]).Value > 0 then Index.IntValue1.Value = 1 -- This is an example code break end end end
Hopefully this helped you Please submit this answer if it worked