Is there any way to turn a table into a folder using typeof ? Like I have an entire table that has values and booleans and tables in it, I want to create a filter where it loops through the table and create the inatances value and also a folder for each table that are inside the main table, and parent each value in their table just like how they were parented in the main table.
function convertToFolder(tab, parent)
local fold = Instance.new("Folder", parent)
for i,val in pairs(tab) do
local t = typeof(val)
if t=="boolean" then
t = "bool"
end
local inst = string.gsub(t, "^%l", function(c) return string.upper(c) end).."Value" ---- will be used when creating object for value
if t =="table" then
convertToFolder(val, fold) ---- Table in Table --> Folder in Folder
else
local obj = Instance.new(inst, fold)
obj.Value = v
--obj.Name = i
end
end
end
P.S: I would recommend changing the indexes in your module to strings so the name is assigned when creating the instances.
you can create a function and insert a for in do loop, after that you just check all the values ans if its a number than it creates an intvalue, if its a string than a string value, etc… and if the type is a table, create a new folder and call the function again. I would recomend giving it a path of a folder.
If you don’t understand, than i can write you the code, but that might take a while.
Not really what I’m asking, I’ve tried this and made a module to handle all type of values, only wanted to have more organized script with less lines to make a filter going through whatever is being added in that Table will turn into a its typeof value instance and will be parented to where it is in the table just like the “Boosts” table in my post ^