How do i add parts to a table?

so i tried this by doing table.instert(table, part) but i found this ony adds a refrence to the part, not an actual part with its own data…

How do i add parts to a table then?

Did you mean something like this

workspace.Part = {
[“Size”] = Vector3.new(1,1,1),
[“Position”] = Vector3.new(0,0,0)
}

?

2 Likes

yes, i had an idea for it and that was making a part encode and decode.

Encode would return a table of all of its properties, size, position, color ect
then you would put that table into the other table

Then decode would be used to go through that table and create a part with all of the properties.

Although i dont want to do all this untill its confirmed this is the easiest way

There is no native GetProperties function unfortunately. You would have to manually type out properties or use an API dump (you can implement an auto update feature if you wanted to). There are topics on API dumps already out there.

luckily ive already done this in the past

So… what is your issue then? You should mark something as a solution.

like i said before, i wanna ensure this is the best way of doing it before i try it

if you’re going to serialize instances & save them to datastores, you should create your own data structure using binary and buffers

you will get massive savings with this method

oh its not for datastores
char limit

You’d have to turn the part into a table of properties if you wanted this to work out.

maybe u can use this function i made:

local AllProperties={
	"Name","Parent","Color","Color3","Material","Reflectance","Transparncy","MaterialVariant","Locked","Archivable","Size","CFrame","CanCollide",
	"CanTouch","CollisionGroup","Anchored","Value","Enabled","Disabled","BrrSkibidiToilet"
}

function getObjectProperties(object)
	local Properties={}
	for i,Name in Properties do
		local success,result = pcall(function() return object[Name] and object[Name]~=object:FindFirstChild(Name) end)
		if success and result then
			Properties[Name]=object[Name]
		end
	end
	
	return Properties
end

Serialization is what you’re looking for. Basically it converts a part to a string containing its data.