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 5 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

01script.Parent.Touched:Connect(function(hit)
02 
03if hit:IsA("Terrain") then
04        print("mui")
05            else           
06 
07    for _,i in  pairs(hit.Parent:GetChildren()) do
08        if i:IsA("BasePart") then
09 
10        hit:BreakJoints()
11        hit.Anchored = false
12        hit.Velocity = Vector3.new(23,90,13)
13        hit.RotVelocity = Vector3.new(141.9,90,121)
14 
15        end
View all 21 lines...

Re-gen script

01script.Parent.Touched:Connect(function(hit)
02 
03if hit:IsA("Terrain") then
04        print("m3i")
05            else
06 
07 
08    for _,i in  pairs(hit.Parent:GetChildren()) do
09        if i:IsA("BasePart") then
10        local clo = hit:clone()                
11local ipos = hit.CFrame
12        clo.Parent = workspace
13    clo.CFrame = ipos      
14        end
15 
16            end
17end
18 
19end)

-- 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 — 5y
0
The parts get destroyed but it wont regen helleric -3 — 5y

1 answer

Log in to vote
0
Answered by 5 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 — 5y
Ad

Answer this question