Here is my code
01 | local model = workspace.Plots [ "1" ] .Building |
02 |
03 | model.ChildAdded:Connect( function () |
04 | for name, child in pairs (model:GetChildren()) do |
05 | child:FindFirstChild( "Hitbox" ).Touched:Connect( function (hit) |
06 | if hit.Parent ~ = child then |
07 | child:Destroy() |
08 | end |
09 | end ) |
10 | end |
11 | end ) |
The child is a model and it has a part under it called Hitbox but in the console it is saying attempt to index nil with Touched
inside ChildAdded, pass the child that gets created and make sure it is the hitbox and then use the touched event
1 | ChildAdded:Connect( function (child) |
2 | --code |
3 | end ) |