I have been working on this for a while now but keep running into this isue. The script takes all children in the folder and then should fill the table in for every part, this works for most of the variables but the last 3 never fill in. I have tried multible things but it just doesn’t do what it is supost to do. I also don’t get errors so I have no idea what could be wrong.
Code:
local DataString = {
["PartName"] = {
Material = nil,
Parent = nil,
ColorR = nil,
ColorG = nil,
ColorB = nil,
PosX = nil,
PosY = nil,
PosZ = nil,
SizeX = nil,
SizeY = nil,
SizeZ = nil,
Anchored = false,
ClassName = nil,
HasChildren = false
}
}
for _, P in pairs(Children) do
local Part = P
DataString.Part.Material = Part.Material
DataString.Part.Parent = Part.Parent.Name
DataString.Part.ColorR = Part.Color.R
DataString.Part.ColorG = Part.Color.G
DataString.Part.ColorB = Part.Color.B
DataString.Part.PosX = Part.Position.X
DataString.Part.PosY = Part.Position.Y
DataString.Part.PosZ = Part.Position.Z
DataString.Part.SizeX = Part.Size.X
DataString.Part.SizeY = Part.Size.Y
DataString.Part.SizeZ = Part.Size.Z
if Part.Anchored == true then
DataString.Part.Anchored = true
else
DataString.Part.Anchored = false
end
DataString.Part.ClassName = Part.ClassName
if Part:GetChildren() == true then
DataString.Part.HasChildren = true
else
DataString.Part.HasChildren = false
end
end
edit:
gethcildren() returns all children in a part as an array {}.
if there are no children, the array will be empty, # gets the length of the array, if the length isn’t greater than 0, there are no children.
Is the part anchored and has children? Also, I don’t know if the HasChildren part works, but I personally would’ve used if #Part:GetChildren() > 0 then. I’ve never used if Part:GetChildren() then, so if it works, just use it.
Hi I figgered it out. It was only the “HasChildren” that gave problems and afther I used your suggestions I got it to work. It now fully works. Thanks everyone