I’m interested in recursion. But this code Roblox gets has me some questions.
function colorAllParts(object, brickColor)
if object:IsA("BasePart") then
object.BrickColor = brickColor
end
for _, child in ipairs(object:GetChildren()) do
colorAllParts(child, brickColor)
end
end
colorAllParts(game.Workspace, BrickColor.Red())
And plus, you are calling the function for every children of workspace. Then each children will call the function for every children, then each children to other children, then the cycle keeps going on and on.
yes but youre calling the function again for all the children in a given object so it will have to have no children left to check at some point and when that point is reached the loop will just stop running