How to extract an instance from table

im want extrack instance from table

Could you provide more information about that? Because I didn’t get the main idea.

im want to save players data(folder)

I think you can use this article:

https://developer.roblox.com/en-us/articles/Saving-Player-Data

And also, you don’t have to extract an instance from a table for saving data.

but me want to save Folder and extract Folder

You cannot save Instances with DataStore service. Folders also are instances, so you cannot save folders.

bruh i mean

function ConvertFolderToTable()…

function ConvertTableToFolder()…

When creating a new thread you are presented with a set of questions. Please ensure you have read through this before making a post, it makes it easier for other developers to help you out.

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
  2. What is the issue? Include screenshots / videos if possible!
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Without more information it is impossible for us to assist you.

1 Like

im want to convert a folder to table and convert table to folder simple.

We aren’t here to write the entire solution for you. Please refer to the developer hub and existing threads before creating your own. As a starting point you could try looking at these threads:

And some relevant pages from the developer hub:

If you are still having trouble, come back after doing this and we can try to help you out some more.

i already make convert folder to table but i can’t extract it

Use the GetChildren() function. It returns a table of the children of an instance.

Edit:
Oops, I didn’t see the rely above.

Try something like this:


local selected
for index, child in pairs(childrenTable) do
 if child:IsA(“Part) then --change to method of selection. For example, child.Name == “Important”
  selected = child
  break
 end
end

on the assumption that you store only folders and numbervalues, intvalues, boolvalues, simple value sorta stuff

toTable = function(Folder)
    local t = {}
    for _, v in next, Folder:GetChildren() do
        t[v.Name] = (not v:IsA"Folder" and v.Value or toTable(v))
    end
    return t
end

toFolder = function(Table)
    local Folder = Instance.new("Folder")
    for i,v in next, Table do
        if type(v) == 'table' then
            local vv = toFolder(v)
            vv.Parent = Folder
            vv.Name = i
        else
            local vv = Instance.new((type(v)=='number' and "Number" or type(v)=='boolean' and "Bool" or type(v)=='string' and "String").."Value", Folder)
            vv.Value = v
            vv.Name = i
        end
    end
end
1 Like

it works

local function ConvertFolderToTable(folder)
	local tabl = {}
	if folder:IsA("Folder") then
		tabl = folder:GetChildren()
	end
	return tabl or {}
end

local function ExtractTableToFolder(tabl,name,pos)
	local folder = nil
	local pos = pos
	local name = name
	if type(tabl) == "table" then
		local folder = Instance.new("Folder")
		
		for _,v in pairs(tabl) do
			v:Clone().Parent = folder
		end
		folder.Parent = pos
	end
end

local x = ConvertFolderToTable(script.Test)

ExtractTableToFolder(x,"Test",script)