So I have a building system, I want to save the structures the player makes. To do so I’ve thought on having various slots that can be swapped/saved/loaded.
Now, I want so those slots are also saved to the cloud, obviosly. The problem is that I’m not sure how I’m supposed to save a folder with many parts in it?
here’s an image of the structure of it
I havent really tried anything because I have no idea on how to do it.
Any help is appreciated
Essentialy you classify the object to save as whatever it is. Think of it like a custom ClassName. Inside the object your function goal is to take the location and size of the parts one by one and save them to copy back in later. Let’s say I have a Model with some parts in it. You want to save it as individual parts with their respective locations and sizes, but you want it all to be recognized as a model and not a bunch of parts, so you tell it that! Message me if you want me to show you first hand, I’m so happy to share skills with passionate people!!
Okay… Could you please explain how can I do this?
I can think of a for loop going through all the parts in it, then I can do save the values in a table. Something like this?
for I, slot in pairs(playerInfo:GetChildren()) do
Slots['slot'..tostring(I)] -- I'm not sure if this will create a directory or not, I'm not that good with tables
If #slot:GetChildren() <= 0 then continue end
for i, piece in pairs(slot) do
Slots['slot'..tostring(I)][piece.Name..tostring(i)] -- Line 6
end
In line 6, how would I save the Size and Position here?
I don’t really understand the part of “Classname” you told me honestly. I haven’t yet got used to tables
local Slots = {}
for I, slot in pairs(playerInfo:GetChildren()) do
local slotName ='slot'..tostring(I)
if #slot:GetChildren() <= 0 then continue end
for i, part in pairs(slot) do
partInfo = {
Size = tostring(part.Size),
Position = tostring(part.Position)
Color = tostring(part.Color3)
Material = part.Material.Name
}
Slots[slotName][piece.Name..tostring(i)] = partInfo
end
end
playerData[Slots]
local Slots = {}
for I, slot in pairs(playerInfo:GetChildren()) do
local slotName ='slot'..tostring(I)
if #slot:GetChildren() <= 0 then continue end
for i, part in pairs(slot) do
partInfo = {
Size = {part.Size.X, part.Size.Y, part.Size.Z},
Position = {part.Position .X, part.Position .Y, part.Position .Z},
Color = {part.Color3.R , part.Color3.G, part.Color3.B},
Material = part.Material.Name
}
Slots[slotName][piece.Name..tostring(i)] = partInfo
end
end
playerData[Slots]