Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

3 comments

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.

0

Oh, I guess we will have to make an extra instance D: Read it now.

0

Congratulations - You've found 1 rep!

This discussion is preserved as it was. New answers, comments, and votes are closed.