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

How do i make a script that deletes the model but keeps the children?

So im making a game like the normal elevator. And i am adding a round where "computer" enters the elevator but when the round is over it disapears. I put all the rounds in lighting help pls

2 answers

✓ Accepted answer
local model = --(Your model)
local children = model:GetChildren()

for i,v in pairs(children) do
	v.Parent = --(Where you want the children to go)
end

model:Destroy()

Use a for i,v in pairs do statement. Basically this just sifts through a table and runs code for every value in the table.

Replace the comments with what is supposed to go there. That script takes all the children of a model and relocates them to wherever you specify. Then after it's done, it deletes the model. If this helped, accept the answer. :)

I'm not very good with this, but the method I'd use'd be to move the children somewhere else. Then delete the model.

Imagine this: You have a model in Workspace named "Model" with 2 parts named "Part1" and "Part2" respectively. You'd want to do:

game.Workspace.Model.Part1.Parent = game.Workspace game.Workspace.Model.Part2.Parent = game.Workspace game.Workspace.Model:Destroy()

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