How to change Vector3.new to CFrame.new when changing orientation?

Hello, I’m trying to make my line of code:

Object.PrimaryPart.Orientation = Vector3.new(0, Rot, 0)

Use CFrame rather than Vector3 without changing the line above it:

Object:SetPrimaryPartCFrame(GetMousePlacementCFrame(Plot, Object)*CFrame.Angles(0,math.rad(Rot),0))

The problem with just getting rid of the Vector3 is that then the orientation is the way the player’s camera faced which was really strange and not the desired effect. The problem with Vector3 is that the whole model needs to change and can only occur with CFrame.

It’s a bit confusing for me. Do you want to move the whole model without changing its orientation?

The model moves perfectly fine but when you move it the Orientation should stay the same unless you rotate it with “R” in a different line of script. With the CFrame you can still move the model but the orientation is your camera’s orientation which I’m confused why that happens and how to prevent that

1 Like

Sorry for my bad english

If I understood it right, you can use the property Position from the CFrame

Something like this:

local rotation = 0  -- add some degrees here when R is pressed
local objectCFrame = CFrame.new(GetMousePlacementCFrame(Plot, Object).Position)  -- we're using this because CFrame.new takes a position and returns 0, 0, 0 orientation
local positionWithRotation = objectCFrame:ToWorldSpace(CFrame.Angles(0, math.rad(rotation), 0))  -- rotating the object

-- moving it
Object:SetPrimaryPartCFrame(positionWithRotation)

Take a look and see if that is what you’re talking about :slight_smile:

1 Like

That was the solution! Thanks so much for helping me and I see how you did it with the :ToWorldSpace. Again, thanks! :smile:

1 Like