How use the mobile joystick to aim a part

In a mobile device or pc, the player move their character using the humanoid walk direction, i want to rotate a part in one axis(y) with it

https://developer.roblox.com/en-us/api-reference/property/Humanoid/MoveDirection

I think i want a rotation (between 0 and 359?) but the ouput is a
“unit vector along the X/Z axis”

wait(4)
script.Parent.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	print(script.Parent.Humanoid.MoveDirection)
--  0.99987041950226, 0, 0.016099214553833
-- -0.96307921409607, 0, 0.26921823620796
-- -0.95814841985703, 0, -0.28627195954323
end)

How i can do?

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local part = Instance.new("Part")
part.Parent = workspace
part.Anchored = true
part.Position = Vector3.new(0, 50, 0)

while task.wait() do
	part.Orientation = Vector3.new(part.Orientation.X, hrp.Orientation.Y, part.Orientation.Z)
end

This will work for both devices.

Sorry, but in the game you dont play with a character, i will hide it anchored
But i find this:

wait(4)

local humanoid = script.Parent:WaitForChild("Humanoid")
script.Parent.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	local md = humanoid.MoveDirection
	--print(Vector3.new(md.X,0,md.Z))
	print(md)

	local angle = math.ceil(math.deg( math.atan2(md.X, -md.Z)) - 0.5)  * -1 -- -1 bc it rotate backwards
	--if angle == -180 then  angle = 0 end --When the player stop, the part look backward i cant fix it (0,0,0 = 180, 180 * -1 = -180)
	warn(angle)
	workspace.SpawnLocation.Orientation = Vector3.new(0,angle,0)
		
end)

It dont work when player stop moving, the part look backwards
And i dont understand the math