Resetting Model CFrame Orientation

Local script

userInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.One and not gameProcessedEvent then

		SubRootPart.RotationGyro.CFrame = CFrame.Angles(0, 0, 0)
		SubRootPart.CFrame = SubRootPart.CFrame * CFrame.Angles(0, SubRootPart.CFrame.Y, 0)
	end
end)

When the user presses one, the models orientation is reset. This works perfectly fine, however, how would I keep the models yaw from being reset?

S̶h̶a̶m̶e̶l̶e̶s̶s̶ ̶s̶e̶l̶f̶ ̶b̶u̶m̶p̶

After further testing I’ve found that SubRootPart.CFrame.Y doesn’t actually change before and after the orientation is reset (https://gyazo.com/b19f9465fff51e02b22b166cf55c83d7).
I had also tried keeping the body gyro yaw rotation angle the same, however this doesn’t as the model always ends up at 49 degrees for whatever reason. (https://gyazo.com/8e073d8a1deda85b9edc86610d34df7c)

i wonder if just

userInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.One and not gameProcessedEvent then
		SubRootPart.CFrame = SubRootPart.CFrame * CFrame.Angles(0, 1, 0)
	end
end)

would work, all this should do is multiply roll and pitch by 0 making them 0 (resetting it) while multiplying yaw by 1 keeping it the same

It does this: https://gyazo.com/1b2dde317b8b574a7271624b146c086d

if inputObject.KeyCode == Enum.KeyCode.One and not gameProcessedEvent then
	local LookVector = SubRootPart.CFrame.LookVector * Vector3.new(1, 0, 1)
	SubRootPart.RotationGyro.CFrame = CFrame.new(SubRootPart.Position, SubRootPart.Position + LookVector)
end

2 Likes