:MoveTo() sending models to incorrect position

I am using the :MoveTo() function to move a vehicle model to a specific part position in workspace. The code is as follows below:

The vehicle is getting moved to the wrong position in workspace.
Desired Part Position: -1662.975, 133.2, -800.725
Actual Incorrect Position: -2813.166, 133.005, -176.11

Server Script:

local function changeVehiclePosition(vehicleModel, part)
	vehicleModel:MoveTo(part.Position)
end

The part is anchored and cancollide is set to false. The part is also raised in the air slightly to ensure vehicles are not sent under the map.

Try PivotTo instead… for models.

1 Like

Don’t forget the pivot point is going to change depending on the primary part unless it doesn’t have one then it’s going off the model’s bounding box

1 Like

Is this the correct way to use PivotTo?

local function changeVehiclePosition(vehicleModel, part)
	vehicleModel = vehicleModel:GetPivot()
	vehicleModel:PivotTo(vehicleModel * CFrame.new(part.Position))
end

I believe you can just do:

vehicleModel:PivotTo(CFrame.new(-1662.975, 133.2, -800.725))

And as Noble pointed out, if it doesn’t have a primary part, it will use the bounding box, so adjust for this if needed.

This did not work, I will keep looking for other solutions

Thank you for the help though!

1 Like

Is there something in the way between the start point and the ending point? like terrain or a basepart? If there is its recommended to use Model:SetPrimaryPartCFrame():

4 Likes

Yes, there are multiple things in the way of the model! I will use Model:SetPrimaryPartCFrame().

1 Like

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