Tried remaking kind of shiftlock

so i tried to make a system where the player is locked to the y axis of the camera.

RunService.RenderStepped:Connect(function()
	local _,rYEE, _ = CFrame.new(RootPart.CFrame.p, workspace.CurrentCamera.CFrame.LookVector * 10000):ToOrientation()
    local rXEE, _, rZEE = RootPart.CFrame:ToOrientation()
    RootPart.CFrame = CFrame.new(RootPart.CFrame.Position) * CFrame.fromOrientation(rXEE, rYEE, rZEE)
end)

thats my code and thought if thats the best way to do it or theres like better ways since I do think its not the best way.

You’re real close! A simpler method is like so:

RunService.RenderStepped:connect(function()
	RootPart.CFrame = CFrame.new(RootPart.Position) * CFrame.Angles(0,Vector3.new(workspace.CurrentCamera.CFrame:ToOrientation()).Y,0)
end)