You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to loop through a folder and add its contents to a table
What is the issue?
The values are not getting added to the table, but the printing works fine. (Comes out as nil)
wlMembers = {}
while true do
wait(1)
for _,v in pairs(wlF:GetChildren()) do
if v and v:IsA("StringValue") then
table.insert(wlMembers, v.Name)
end
end
for index, value in pairs(wlMembers) do
print(index, value)
end
end
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried fiddling around with everything I know how to do, all help is appreciated <3
local dictionary = {ThisIsAKey = "ThisIsAValue"}
local array = {"Value1", "Value2"}
for Key, Value in pairs(dictionary) do
print(Key, Value)
--> ThisIsAKey ThisIsAValue
end
for Index, value in ipairs(array) do
print(Index, Value)
--> 1 Value1
--> 2 Value2
end
if you try using ipairs on a dictionary or vise versa, it won’t go through it, iirc.
local wlMembers = {}
while true do
wait(1)
for _,v in ipairs(wlF:GetChildren()) do
if v and v:IsA("StringValue") then
table.insert(wlMembers, v.Name)
end
end
for index, value in pairs(wlMembers) do
print(index, value)
end
end
I have tried your guys’ suggestions but the output is still empty, even when I added a few string values.
Yes, but lua itself doesn’t contain dictionaries in the code itself, you are able to “make” dictionaries but in the end they get converted back to [1] = {“Yeet” = “Yeet”} after it compiles.
Add some prints to see what data is being added aka
local wlMembers = {}
while true do
wait(1)
for _,v in ipairs(wlF:GetChildren()) do
if v and v:IsA("StringValue") then
print(v.Name, v.Value)
table.insert(wlMembers, v.Name)
end
end
for index, value in pairs(wlMembers) do
print(index, value)
end
end