How to change orientation with CFrameValue?

Hi there! I’m trying to figure out how I can alter the orientation in the same way I’m altering the position in this script:

local PT = workspace:WaitForChild("Rig"):WaitForChild("HumanoidRootPart")
local POS = game:GetService("ReplicatedStorage"):WaitForChild("Replay"):WaitForChild(plr.Name):FindFirstChild(Count).Value
PT.CFrame = CFrame.new(POS.Position)
-- same thing here but with orientation

The POS variable is a CFrameValue

For reference, this is what I have so far. As you can see, I’m making a replay system. It’s setting the position correctly, I just need it to set the orientation correctly, too.
Just trying to set PT’s CFrame orientation to be this:
image

Thanks!! :slight_smile:

CFrames have both a position and rotation component. Sounds like you should just set the CFrame to the CFrameValue’s value and if you need rotation then update CFrameValue.Value?

Mind providing code?
I’ve been trying for a long time to figure out how to get the orientation from a CFrame value.
Plus, I can’t find anything about it in the documentation either.

Thanks!

Maybe …

PT.CFrame *= CFrame.fromEulerAnglesXYZ(#, #, #)

Something like

local humanoidRootPart = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart
local position = Vector3.new(10, 0, 5) humanoidRootPart.CFrame = CFrame.new(position)
local rotation = CFrame.fromEulerAnglesXYZ(math.rad(45), math.rad(90), math.rad(-30))
humanoidRootPart.CFrame *= rotation

to modify the orientation of a part using a CFrame, you can utilize the CFrame.new() constructor by providing the desired position and rotation values as arguments

local PT = workspace:WaitForChild("Rig"):WaitForChild("HumanoidRootPart")
local POS = game:GetService("ReplicatedStorage"):WaitForChild("Replay"):WaitForChild(plr.Name):FindFirstChild(Count).Value

-- position
PT.CFrame = CFrame.new(POS.Position)

-- orientation
PT.CFrame = CFrame.new(PT.Position, POS.Position)

i’m not exactly sure if that’s what you’re looking for

This changes the orientation, but for some reason, it’s not setting the orientation correctly.

Here’s a video of it. As you can see, im making a replay system. It sets the player’s position correctly, but it doesn’t set the orientation.

In the code you provided, the orientation changes, but it doesnt change in the correct direction.
Thanks for the response! Let me know if you find another way to fix this. :slight_smile:

How could I make this work with the CFrame value?

Put the part where you want it to be and copy the numbers to that script.

Mind elaborating or providing a brief code example? I’m not exactly sure how to get those numbers.

Nevermind, fixed it!
Apparently, you can just set the CFrame to be the CFrameValue:

local PT = workspace:WaitForChild("Rig"):WaitForChild("HumanoidRootPart")
local POS = game:GetService("ReplicatedStorage"):WaitForChild("Replay"):WaitForChild(plr.Name):FindFirstChild(Count).Value
PT.CFrame = POS

Hopefully this hels someone down the road! :slight_smile:

Just general ways to set position and/or rotation.