I have made model exporter, it basically saves all the data of a part/meshpart into a json file.
but when i import it with the values saved, the meshpart scaling is broken
from this

to this
Here is my code
local HttpService = game:GetService("HttpService")
local partsInModel = {}
local modelPart = script.Parent
for index,part in pairs(modelPart:GetDescendants()) do
part.Name = "Part"..index
end
for i, part in modelPart:GetDescendants() do
if part:IsA("Part") then
local properties = {}
properties["Type"] = "Part"
properties["Color"] = tostring(part.Color)
properties["Material"] = tostring(part.Material.Name)
properties["CFrame"] = tostring(part.CFrame)
properties["Size"] = tostring(part.Size)
properties["Reflectance"] = part.Reflectance
properties["Transparency"] = part.Transparency
properties["Shape"] = tostring(part.Shape.Name)
partsInModel[part.Name] = properties
elseif part:IsA("MeshPart") then
local properties = {}
properties["Type"] = "MeshPart"
properties["Color"] = tostring(part.Color)
properties["Material"] = tostring(part.Material.Name)
properties["CFrame"] = tostring(part.CFrame)
properties["Size"] = tostring(part.Size)
properties["Reflectance"] = part.Reflectance
properties["Transparency"] = part.Transparency
properties["MeshId"] = part.MeshId
properties["TextureID"] = part.TextureID
properties["DoubleSided"] = part.DoubleSided
partsInModel[part.Name] = properties
end
end
local json = HttpService:JSONEncode(partsInModel)
print(json)
local model = Instance.new('Model')
model.Name = modelName
model.Parent = modelsImporterFolder
local decode = HttpService:JSONDecode(json)
for i, partDecode in pairs(decode) do
if partDecode.Type == 'Part' then
local part = Instance.new("Part")
part.CFrame = decodeCFrame(partDecode.CFrame)
part.Reflectance = partDecode.Reflectance
part.Transparency = partDecode.Transparency
part.Material = decodeMaterial(partDecode.Material)
part.Color = decodeColor3(partDecode.Color)
part.Shape = decodeShape(partDecode.Shape)
part.Size = decodeSize(partDecode.Size)
part.Parent = model
part.Anchored = true
elseif partDecode.Type == 'MeshPart' then
local part = Instance.new("MeshPart")
part.CFrame = decodeCFrame(partDecode.CFrame)
part.Reflectance = partDecode.Reflectance
part.Transparency = partDecode.Transparency
part.Material = decodeMaterial(partDecode.Material)
part.Color = decodeColor3(partDecode.Color)
part.Size = decodeSize(partDecode.Size)
part.MeshId = partDecode.MeshId
part.TextureID = partDecode.TextureID
part.Parent = model
part.Anchored = true
end
end
