Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

script that destroys a part of the building and re-gens but, it wont re-gen how do i fix?

Asked by 4 years ago

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.

Destroy script

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

0
Honestly, I think that placing them in seperate scripts will mess up the sequence of the result, so the regen may have happened before the part destroyed itself. Seeing that you have waits in the Destroy script and the regen does not, I think it is likley that this is what happened. My conclusion to you is to add wait(1) in the re-gen script before line 10. WarmFireBlaze1 15 — 4y
0
The parts get destroyed but it wont regen helleric -3 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Honestly, I think that placing them in seperate scripts will mess up the sequence of the result, so the regen may have happened before the part destroyed itself. Seeing that you have waits in the Destroy script and the regen does not, I think it is likley that this is what happened. My conclusion to you is to add wait(1) in the re-gen script before line 10.

P.S sorry I accidently added the post comments as well :]... I am new to this so bear with me :)

0
did not work helleric -3 — 4y
Ad

Answer this question