How can I move a model using only the X position and no other?

How can I move the model position without touching the other coordinates?
without touching y,z

I already know this script, but it doesn’t work for my game.
--------------
local model = game.Workspace.Model

model:MoveTo(Vector3.new(30,model.PrimaryPart.Position.Y,model.PrimaryPart.Position.Z))
---------------------
An example of what I want to do is:

local model = game.Workspace.Model

model.PrimaryPart.Position.X = 20

1 Like

So you want to change the X coordinate of the model? Does your model have a PrimaryPart?

1 Like

yes ,but if I didn’t have it, it doesn’t matter what I want to know is how to move a model without touching the other coordinates

1 Like

Well, this is a simpler example:

local p1 = workspace.Part1
local p2 = workspace.Part2

p2.Position = Vector3.new(50,p1.Position.Y,p1.Position.Z)

You would do something like this, but use PivotTo() for models. The function needs a CFrame parameter.

1 Like

Single coordinates are read only properties so you cannot change their values directly. What you can do is sum a vector containing the amount of studs you want to increase/decrease a coordinate value of to it’s current position.

model.PrimaryPart.Position += Vector3.new(100, 0, 0) -- adds 100 studs to the X coordinate
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.