I have tried this, but I seem to be having no luck.
local chil = game.ReplicatedStorage.Maps:GetChildren()
for i,v in pairs(chil) do
local num = 1
table.insert(_G.Dialog.Options,num,chil.Name)
num = num + 1
end
Any help would be appreciated
I have tried this, but I seem to be having no luck.
local chil = game.ReplicatedStorage.Maps:GetChildren()
for i,v in pairs(chil) do
local num = 1
table.insert(_G.Dialog.Options,num,chil.Name)
num = num + 1
end
Any help would be appreciated
It looks like you're trying to combine the two methods of iterating a table: the key-value pair method, and the list/index method. If you want to use pairs, that's fine, but you may as well make use of the variables that they call for:
local maps = {} -- New table
local chil = game.ReplicatedStorage.Maps:GetChildren()
for i,v in pairs(chil) do
table.insert(maps,v.Name)
end
The use of the global table is not recommended. If you need to share a table between scripts, consider using a module script instead and just return the table at the end of the script.
could alsp use get desents
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
pls use code block and not quotes
chil is the table (array) and chil.Name is trying to access the value held in the key called Name. In the loop v ins the child so _G.Dialog.Options[#_G.Dialog.Options+1] = v.Name is what you need
I would also avoid the use of _G