Hello, I'm doing a recursive function, on some models and inside there are other models and part, well then it throws me an error of stack overflow, and the script stops working, what can I do to fix it ?, I'm new and it's not that know a lot, thanks.
function ChildEdi() for i, child in pairs(model:GetChildren()) do if child:IsA("BasePart") then child.Touched:Connect(onModelTouched) elseif child:IsA("Model") then ChildEdi(child) end end end ChildEdi(model)
The problem is that you are putting an argument into the function where no parameter exists. Simply add the parameter:
function ChildEdi(model) for i, child in pairs(model:GetChildren()) do if child:IsA("BasePart") then child.Touched:Connect(onModelTouched) elseif child:IsA("Model") then ChildEdi(child) end end end ChildEdi(model)
Hope this helps and have a great day scripting!