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

How do I move a model using Vector3?

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.

1 comment

0

SetPrimaryPartCFrame()

1 answer

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.

1 comment

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?

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