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
model = script.Parent.Parent:Clone()

function tower(part)
    if part.Parent:findFirstChild("Humanoid") and game.Players:playerFromCharacter(part.Parent) then
        local old = script.Parent.Parent
        local oldParent = old.Parent
        old:Remove()
        wait(4)
        local new = model:Clone()
        new.Parent = oldParent
        old:Destroy()
    end
end

script.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().

local model = script.Parent.Parent --Local variables are more efficient!
local copy = model:Clone()

function tower(part)
    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.
        local new = copy:Clone()
        local parent = model.Parent
        model:Destroy()
        wait(4)
        new.Parent = parent
        new:MakeJoints()
    end
end

script.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