How do you change 1 value of a cframe? (in orientation)

trying to change the orientation of z value on a joint

cant find anyway to do this pls help

Rshoulder.C0.Orientation =  CFrame.new(nil,nil, cameradirection)

Rshoulder.C0 = CFrame.Angles(Rshoulder.C0.X, Rshoulder.C0.Y,cameradirection)

tried both of these, they dont work

local NewZ = --value in radians
local OldCFrame = Rshoulder.C0
local OldX, OldY, OldZ = OldCFrame:ToEulerAnglesXYZ() -- This function returns CFrame's Angles in Radians

-- Get Old Position, and Old X and Y angle values, and set the new Z value
Rshoulder.C0 = CFrame.new(OldCFrame.Position) * CFrame.Angles(OldX, OldY, NewZ)
1 Like

Not CFrame.Angle, its CFrame.fromOrientation, so its fit with the op context

1 Like

thanks this is good

but im having a issue with how am trying to use it

first vid is using cframe.FromOrientation
second vid is cframe.Angle


am trying to achieve the first video effect but properly on the arm like this
image

i wanna make it so if the cameras looking up, the camera will follow heres the script am using

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Rshoulder = game.Players.LocalPlayer.Character.Torso["Right Shoulder"]

game:GetService("RunService").RenderStepped:Connect(function()
	
	print(workspace.CurrentCamera.CFrame.LookVector.Y*90)
	
	local cameradirection = workspace.CurrentCamera.CFrame.LookVector.Y*90
	
	local NewZ = math.rad(cameradirection)--value in radians
	local OldCFrame = Rshoulder.C0
	local OldX, OldY, OldZ = OldCFrame:ToEulerAnglesXYZ() -- This function returns CFrame's Angles in Radians
Rshoulder.C0 = CFrame.new(OldCFrame.Position) * CFrame.fromOrientation(OldX, OldY, NewZ)
end)
local NewZ = --value in radians
local OldCFrame = Rshoulder.C0
local OldX, OldY, OldZ = OldCFrame:ToOrientation() -- This function returns CFrame's Angles in Radians

-- Get Old Position, and Old X and Y angle values, and set the new Z value
Rshoulder.C0 = CFrame.new(OldCFrame.Position) * CFrame.fromOrientation(OldX, OldY, NewZ)

Edited script from @FP_Nation script with the fixed orientation order

1 Like

thnaks this works
30chasr wgsdrgreg

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