I have done lots of stuff like this and never have I encountered this problem before.
During the saving of playerdata, I am looping through the children of a folder. The folder has one objectvalue which links to a planet the player owns and the rest of the children are models of planets.
Here’s the portion of the datasaving script I’m having problems with:
for i,v in pairs(plrplanets:GetChildren()) do
if v:IsA("Model") then
plrplanetsitems[v.Name] = {
["acidity"] = v:GetAttribute("acidity"),
["age"] = v:GetAttribute("age"),
["gravity"] = v:GetAttribute("gravity"),
["groundpressure"] = v:GetAttribute("groundpressure"),
["humidity"] = v:GetAttribute("humidity"),
["materialdensity"] = v:GetAttribute("materialdensity"),
["mined"] = v:GetAttribute("mined"),
["radiation"] = v:GetAttribute("radiation"),
["temperature"] = v:GetAttribute("temperature"),
}
else
local addplanet = v
plrplanets[addplanet.Value.Name] = { --error on this line
["acidity"] = addplanet.Value:GetAttribute("acidity"),
["age"] = addplanet.Value:GetAttribute("age"),
["gravity"] = addplanet.Value:GetAttribute("gravity"),
["groundpressure"] = addplanet.Value:GetAttribute("groundpressure"),
["humidity"] = addplanet.Value:GetAttribute("humidity"),
["materialdensity"] = addplanet.Value:GetAttribute("materialdensity"),
["mined"] = addplanet.Value:GetAttribute("mined"),
["radiation"] = addplanet.Value:GetAttribute("radiation"),
["temperature"] = addplanet.Value:GetAttribute("temperature"),
}
end
end
When looping through, I get an error (which the location is marked on my code) that reads
Planet of Player1 is not a valid member of Folder "Player1.Planets"
So what I’m getting from this is it is looping through the data, noticing an object value, getting the value of it and for some reason going “Hey, this area of workspace you’ve referenced from is not in this folder!” - WHO CARES? I specifically WANT you to reference that value! I don’t see why it should matter if it’s a child of the folder or not, just ADD IT!
I’ve never encountered this problem before. I use lots of these objectvalues in my game and frequently reference them in loops. I’ve restarted studio which has done nothing to help as from experience and from other posts have learnt that studio can be at fault. Appears not this time…