I’ll see if that works when I get on my computer in the morning.
Okay, the error on line 57 is in the initProps function, which has:
for _, Prop in pairs(Properties[obj.ClassName]) do
The full spot there can be found in the initProps function.
I will list all the functions for saving, which are are a few (3).
The Save.Encrypt() function:
function module.Encrypt(objs)
return HttpService:JSONEncode(InitProps(objs))
end
Then, the initProps function:
function InitProps(objects)
local tableToSave = {}
for _, obj in pairs(objects) do
local class = obj.ClassName
local t = tableToSave[class]
if not(t) then
tableToSave[class] = {}
t = tableToSave[class]
end
local add = {}
for _, Prop in pairs(Properties[obj.ClassName]) do -- this is the line that makes the error
add[Prop] = Serialize(obj[Prop])
end
local children = obj:GetChildren()
if #children > 0 then
add["Children"] = InitProps(children)
end
table.insert(t, add)
end
return tableToSave
end
Then, the serialize function:
function Serialize(prop)
local typ = typeof(prop)
local r
if typ == "BrickColor" then
r = tostring(prop)
elseif typ == "CFrame" then
r = {pos = Serialize(prop.Position), rX = Serialize(prop.rightVector), rY = Serialize(prop.upVector), rZ = Serialize(-prop.lookVector)}
elseif typ == "Vector3" then
r = {X = prop.X, Y = prop.Y, Z = prop.Z}
elseif typ == "Color3" then
r = {Color3.toHSV(prop)}
elseif typ == "EnumItem" then
r = {string.split(tostring(prop), ".")[2], string.split(tostring(prop), ".")[3]}
else
r = prop
end
return r
end
Also, the error is:
“error generating data: ServerScriptService.Serializer:57: invalid argument #1 to ‘pairs’ (table expected, got nil) for slot Slot1 for plr GalacticLemon_Aj”.
That didn’t seem to help. I do know that the blocks exist, because when it prints the block’s name when it goes in the loop.
The error is saying that you’re passing nil to the pairs
function, meaning that Properties[obj.ClassName]
is nil. In other words, there’s no key in the Properties
table that matches obj
's ClassName.
Try putting a print statement before the for loop to see what class isn’t included within the Properties
table.
print(obj.ClassName, Properties[obj.ClassName])
When I use that, it prints with:
Part ▼ {
[1] = “Name”,
[2] = “Position”,
[3] = “Size”,
[4] = “Transparency”,
[5] = “BrickColor”,
[6] = “CanCollide”,
[7] = “CFrame”,
[8] = “Anchored”,
[9] = “Shape”,
[10] = “Material”
}
StringValue nil
- this and the message above are both from line 56, the print you suggested to add.
error generating data: ServerScriptService.Serializer:58: invalid argument #1 to 'pairs' (table expected, got nil) for slot Slot1 for plr GalacticLemon_Aj