this is a script where a ball hits a building and destroys the pats it hit and a moment later the parts that got hit by the ball regen/remake them self but it wont work idk why no errors.

script.Parent.Touched:Connect(function(hit)

if hit:IsA("Terrain") then
        print("mui")
            else            

    for _,i in  pairs(hit.Parent:GetChildren()) do
        if i:IsA("BasePart") then

        hit:BreakJoints()
        hit.Anchored = false
        hit.Velocity = Vector3.new(23,90,13)
        hit.RotVelocity = Vector3.new(141.9,90,121)

        end
        wait()
            hit:Destroy()
            end
end

end)

re-gen script

script.Parent.Touched:Connect(function(hit)

if hit:IsA("Terrain") then
        print("m3i")
            else 


    for _,i in  pairs(hit.Parent:GetChildren()) do
        if i:IsA("BasePart") then
        local clo = hit:clone()                 
local ipos = hit.CFrame 
        clo.Parent = workspace
    clo.CFrame = ipos       
        end

            end
end

end)

i tried to put both in the same script but it wont work also, the parts get destroyed but it won re-gen

2 comments

0

Try cloning the building model before it gets hit so when it’s cloned it clones a fixed building instead of a broken one

0

but i don't wan't to repair the hole thing just the thing that were destroyed