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

How do you clone models to a specific position?

Asked by 8 years ago

Normally to go about cloning a part to a specific position you would have something similar to this:

local a = game.Workspace.Part:Clone()
a.Parent = game.Workspace
a.Position = Vector3.new(1,1,1)

Now, what if you wanted to clone a model with multiple parts to a specific position?

You can have this:

local a = game.Workspace.Model:Clone()
a.Position = Vector3.new(1,1,1)

Except this wouldn't work because the property 'Position' is non-existent in a model. So, you could be a little more clever and come up with a for i v in pairs loop:

for i, v in pairs(game.Workspace.Model:GetChildren()) do
        local b = v:Clone()
        b.Parent = game.Workspace
        b.Position = Vector3.new(1,1,1)
end

However, this wouldn't work either because it clones each part in the model to the same position. So if anyone out there knows, how would you clone a model to a specific position? Thank you for your help.

0
Try :SetPrimaryPartCFrame(), :MoveTo(), or :TranslateBy(), they all move models theCJarmy7 1293 — 8y
0
Thanks for the help, I will try those. TheEnderShot 14 — 8y
2
MoveTo() is the easiest way, but there are some major flaws with it. First of all, you can't use a CFrame value, and the model will often not get teleported to the exact position because it can't get moved into any other object. Using Primary Parts with CFrame is what I would use. User#11440 120 — 8y

Answer this question