so i made a simple function that is supposed to find a child in a branch called children, and if it finds it then get the children.
heres the function:
local function getBranchChildren(branch)
if branch:FindFirstChild("Children") ~= nil then
for i,v in pairs(branch.Children:GetChildren()) do
table.insert(children,v.Value)
getBranchChildren(v.Value)
end
end
end
everything is fine but when it doesnt find “Children”, instead of just not running the function it gives me an error.
i have tried changing it to waitforchild but then i just got this
the ‘branch’ object is nil, which is why you can’t use the FindFirstChild function from it, and the variable is being passed through a function argument.
To solve this, find wherever the function was called and make sure whatever is being passed through it is an existing object.
For instance, getBranchChildren() will set the ‘branch’ object as nil, because you never provided an argument with the function.