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

How to SetPrimaryPartCFrame() while preserving rotation WITHOUT MoveTo?

MoveTo changes the Y location to an unwanted value. The only option is SetPrimaryPartCFrame(), but this changes the orientation to an unwanted value. How should I proceed?

1 comment

0

What is your code?

2 answers

Give this a try:

model:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,0,0), model.PrimaryPart.Position))

5 comments

0

Change 0,0,0 to your wanted position of course.

0

ok

0

ok

0

Did it work?

0

This will move the model to the desired location, but it will be pointed towards its last location

To preserve orientation, you have to add a Vector3 to the current CFrame:

local cf = model:GetPrimaryPartCFrame()
model:SetPrimaryPartCFrame(cf + Vector3.new(x, y, z) - cf.Position)

Vector3.new(x, y, z) - cf.Position gets the difference between where you want it and where it currently is. We add that difference to the current CFrame to get the correct position without changing orientation.

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