So for example, I have this script:
01 | local model = workspace.Plots [ "1" ] .Building |
02 |
03 | model.ChildAdded:Connect( function () |
04 | for name, child in pairs (model:GetChildren()) do |
05 | child:WaitForChild( "Hitbox" ).Touched:Connect( function (hit) |
06 | if hit.Parent ~ = child then |
07 | child:Destroy() |
08 | end |
09 | end ) |
10 | end |
11 | end ) |
Basically, it creates a new part and if it is touching that other part it will check if it has the same parent. If it doesn't it will destroy that model.
01 | local model = workspace.Plots [ "1" ] .Building |
02 |
03 | model.ChildAdded:Connect( function () |
04 | for name, child in pairs (model:GetChildren()) do |
05 | child:WaitForChild( "Hitbox" ).Touched:Connect( function (hit) |
06 | if hit.Parent.Name = = child.Parent.Name then |
07 | child:Destroy() |
08 | end |
09 | end ) |
10 | end |
11 | end ) |
boop