Issue with getting part properties

I’m trying to make a system that can save information about parts and then load them in later. It works by looping through everything in a folder and then saving it to a table. I tried to test it out, using this part here:

When I print it out, this is what it comes out as:

[{"Anchored":true,"Reflectance":0,"CanCollide":true,"Material":null,"Color":null,"Transparency":0,"Position":null,"Orientation":null,"Class":"Part","Size":null}]

Certain properties like size, orientation, color and a few more come out as null, and I don’t know why. I’ve tried using tostring() on some of the properties but it still won’t work. Here is the modulescript responsible for saving and loading things:

local http = game:GetService("HttpService")

function module.Save()
	local t = {}
	for _,v in pairs(game.Workspace.Game:GetChildren()) do
		if v:IsA("BasePart") or v:IsA("Part") then
			local part = {
				Color = tostring(v.Color),
				Material = tostring(v.Material),
				Anchored = v.Anchored,
				Transparency = v.Transparency,
				Reflectance = v.Reflectance,
				Size = v.Size,
				Position = v.Position,
				CanCollide = v.CanCollide,
				Orientation = v.Orientation,
				Class = v.ClassName,
			}
			table.insert(t,part)
		end
	end
	return http:JSONEncode(t)
end

Any help is appreciated!

Size, orientation, colour and position are not single values. For example, position consists of a vector3 of an X, Y and Z value and by default “Size” can only store a single value. So instead you would have to store PositionX = v.Position.X etc
Alternatively set a vector3 variable to the properties instead.

1 Like