Turning Humanoid.MoveDirection into CFrame.Angles

Trying to covert Humanoid.MoveDirection into CFrame Angles to rotate the player, I tried setting Humanoidrootpart Cframe to the moveDirection, it works but keeps snapping the player back if the player is moving:

local rootPos = hmdrootpart.CFrame.p
local moveDir = hmd.MoveDirection
moveDir = Vector3.new(moveDir.X, 0, moveDir.Z)
if moveDir.Magnitude > 0.5 then
	hmdrootpart.CFrame = CFrame.new(rootPos, rootPos + moveDir)	
end

You can lerp if you want smoother transitions.

local Game = game
local RunService = Game:GetService("RunService")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

while true do
	local Time = 0
	while true do
		if Humanoid.MoveDirection.Magnitude == 0 then RunService.RenderStepped:Wait() continue end
		if Time > 2.5 then break end
		local Pivot = Character:GetPivot()
		local CF = CFrame.new(Pivot.Position, Pivot.Position + Humanoid.MoveDirection)
		Character:PivotTo(Pivot:Lerp(CF, Time / 2.5))
		Time += RunService.RenderStepped:Wait()
	end
end

Increase/decrease ‘2.5’ to change the transition’s speed.

what if i want to do it in a server script?

The character’s position will replicate to the server.

I know itll replicate to the server but what if i want to do it on a server script, is there a way to achieve it?

you mention the humanoid and character of the player you wish to remotely (via server) modify