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

How do I move a model using Vector3?

Asked by 5 years ago

I'm working on a game and suddenly I figured out I needed to move a model. I know how to move a brick but not a model. The reason i'm confused is that there is no position tag in a model.

0
SetPrimaryPartCFrame() DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

To move the model, make sure you have a "PrimaryPart" set first, this is a part that should be parented under the model.

Next, you need to use the :SetPrimaryPartCFrame() function to move the model by small increments, or the :MoveTo() function for a sudden movement

MoveTo immediately moves the model to the set location

workspace.Model:MoveTo(Vector3.new(0, 0, 0))

SetPrimaryPartCFrame can be used to move the model immediately

workspace.Model:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))

SetPrimaryPartCFrame can also be used to move the model incrementally

local a = 0

repeat
    a = a + 1
    workspace.Model:SetPrimaryPartCFrame(workspace.Model.Center.CFrame + Vector3.new(0, 0, 1))
    wait()
until a == 100

The second example makes the model move for 100 studs in the Z-Direction (until a = 100), the PrimaryPart is also named "Center" in the example.

0
what is this: "You need to use the SetPrimaryPartCFrame() function to move the model by small increments, or the MoveTo() function for a sudden movement" and then you later say that SetPrimaryPartCFrame() can also do a sudden movement? what? DeceptiveCaster 3761 — 5y
Ad

Answer this question