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.
01 | function ChildEdi() |
02 | for i, child in pairs (model:GetChildren()) do |
03 | if child:IsA( "BasePart" ) then |
04 | child.Touched:Connect(onModelTouched) |
05 | elseif child:IsA( "Model" ) then |
06 | ChildEdi(child) |
07 | end |
08 | end |
09 | end |
10 |
11 | ChildEdi(model) |
The problem is that you are putting an argument into the function where no parameter exists. Simply add the parameter:
01 | function ChildEdi(model) |
02 | for i, child in pairs (model:GetChildren()) do |
03 | if child:IsA( "BasePart" ) then |
04 | child.Touched:Connect(onModelTouched) |
05 | elseif child:IsA( "Model" ) then |
06 | ChildEdi(child) |
07 | end |
08 | end |
09 | end |
10 |
11 | ChildEdi(model) |
Hope this helps and have a great day scripting!