hello! i’m having issue in my script “Argument 1 missing or nil” i tried everything to fix it and looked at other people forums about this error but didnt find an solution
local Assets = workspace:FindFirstChild("Assets")
local Objects = Assets:FindFirstChild("Objects")
local Planets = Assets:FindFirstChild("Planets")
local SolarSystems = Assets:FindFirstChild("SolarSystems")
for i, v in pairs(Planets:GetDescendants()) do
local SystemToSearchFirst = v:GetAttribute("SolarSystem")
local SystemToSearch = SolarSystems:FindFirstChild(SystemToSearchFirst) -- Error is here
if SystemToSearch:FindFirstChild("Planets") then
v.Parent = SystemToSearch:FindFirstChild("Planets")
else
local PlanetsInstance = Instance.new("Folder")
PlanetsInstance.Parent = SystemToSearch
PlanetsInstance.Name = "Planets"
v.Parent = PlanetsInstance
end
end
That error indicates that SystemToSerchFirst is not finding the attribute of v, or v does not have the attribute "SolarSystem". I would make sure that v has the attribute or that you’re spelling it correctly.
local PlanetsInstance = SystemToSearch:FindFirstChild("Planets") or Instance.new("Folder")
PlanetsInstance.Name = "Planets"
PlanetsInstance.Parent = SystemToSearch
v.Parent = PlanetsInstance
Also you can try debugging by printing v.
Also you’re using GetDescendants not GetChildren.
GetChildren get the children which actually have the Parents set to the folder.
GetDescendants include the children of children etc.