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

Why doesn't the model regen connect to the ground? [Answered]

Asked by
Marios2 360 Moderation Voter
10 years ago
01model = script.Parent.Parent:Clone()
02 
03function tower(part)
04    if part.Parent:findFirstChild("Humanoid") and game.Players:playerFromCharacter(part.Parent) then
05        local old = script.Parent.Parent
06        local oldParent = old.Parent
07        old:Remove()
08        wait(4)
09        local new = model:Clone()
10        new.Parent = oldParent
11        old:Destroy()
12    end
13end
14 
15script.Parent.Touched:connect(tower)

For some reason, when i regen the model described in there, all the parts are disconnected from each other (Meaning that, instead of requiring explosions to be destroyed, it gets destroyed by it's own) What to?

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

Well, first off, playerFromCharacter()is deprecated. Use GetPlayerFromCharacter instead.

Second, you're doing old:Remove() (which is also deprecated, use Destroy() instead.) and then old:Destroy(). If you removed it, why would you bother destroying it?

Anyways, to fix your main problem, you must use the MakeJoints() method. Here, I cleaned up your code and added MakeJoints().

01local model = script.Parent.Parent --Local variables are more efficient!
02local copy = model:Clone()
03 
04function tower(part)
05    if game.Players:GetPlayerFromCharacter(part.Parent) then --No need to check for a humanoid, as long as it's a player it will have one.
06        local new = copy:Clone()
07        local parent = model.Parent
08        model:Destroy()
09        wait(4)
10        new.Parent = parent
11        new:MakeJoints()
12    end
13end
14 
15script.Parent.Touched:connect(tower)

I hope i helped!

0
No, that did not help. When i regened the tower after destroying it, it came back exactly as i had destroyed it. Maybe if you had backed up the model first so that backup is loaded? I tried to fix that script by myself but i found nothing. Marios2 360 — 10y
0
Oh, I guess we will have to make an extra instance D: Read it now. Perci1 4988 — 10y
0
Congratulations - You've found 1 rep! Marios2 360 — 10y
Ad

Answer this question