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

How would I move an entire model rather than each part individually in a model?

Asked by 6 years ago

:I'm making a script that lets you move models in-game, but I don't know how to do this without moving each part individually. Most of my structures are pretty detailed and can use dozens of parts, so I'm not too keen on going that route. Is there any way to move the entire model through script?

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
workspace.Model:MoveTo(Vector3.new(x,y,z))

but again if the model is inside of something it will raise the Y value (go upward) until nothing is in the way. When moving a model, it uses the PrimaryPart chosen. If no primary part is chosen it will use the root part of the model.

If you dont want to worry about that, you can do this

local model = game.Workspace.Model

model:SetPrimaryPartCFrame(CFrame.new(5,5,5)) -- 5,5,5 can be any position you want
0
The second script worked, thanks for all your help :) EnderGamer358 79 — 6y
0
np :) PoePoeCannon 519 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

If you want to move it just do this. Pretend the model is in workspace and named "Model"

workspace.Model:MoveTo(12,42,14) -- Just put in the cordinates
0
First off, that was quick :D, second this answer is kind of vague, I'd need to know how to get the position of the "center" of the model because it's required for the scripts I'm using. EnderGamer358 79 — 6y
0
This moves the model to the desired coordinates, but it moves on top of whatever is there. I suggest using SetPrimaryCFrame instead (Look it up), It sets the model's primary part to the excat location zyrun 168 — 6y
0
Jeez these answers are comin in fast XD, finally I tried the method in the answer and it just gave me an error "Unable to cast double to Vector3", so I'll see if the SetPrimaryCFrame is any good. EnderGamer358 79 — 6y
0
^ gold forgot to add “Vector3.new()” into the parentheses which is why you’re getting an error. Just add that in the parentheses and put the numbers in the parentheses of the “Vector3.new()”. User#20279 0 — 6y
0
of you could do MoveTo(Vector3.new(12,42,14)) although MoveTo is not the best way ever to move a model but it is easy goldstorm950 65 — 6y
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The best way to go at this would be to use :SetPrimaryPartCFrame

Of course, you'll need to make sure that the model has a primary part set.

An example:

local model = game.Workspace.Part
local part = game.Workspace.MovePart

model:SetPrimaryPartCFrame(movepart.Position)

Answer this question