function CharacterRealism.ComputeLookAngle(p,b,E)local l=FpsCamera:IsInFirstPerson()local m,M,D=0,0,1 if not b then local E=workspace.CurrentCamera b=E.CFrame.LookVector end if b then local E=p.Player.Character local z=E and E:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if z and z:IsA("\066\097\115\101\080\097\114\116")then local E=z.CFrame m=-E.RightVector:Dot(b)if not l then D=math.clamp(E.LookVector:Dot(b)*10,-1,1)end end M=b.Y end if E then D=E end m*=D M*=D return m,M end
-- Computes the look-angle to be used by the client.
-- If no lookVector is provided, the camera's lookVector is used instead.
-- useDir (-1 or 1) can be given to force whether the direction is flipped or not.

function CharacterRealism:ComputeLookAngle(lookVector, useDir)
	local inFirstPerson = FpsCamera:IsInFirstPerson()
	local pitch, yaw, dir = 0, 0, 1

	if not lookVector then
		local camera = workspace.CurrentCamera
		lookVector = camera.CFrame.LookVector
	end

	if lookVector then
		local character = self.Player.Character
		local rootPart = character and character:FindFirstChild("HumanoidRootPart")

		if rootPart and rootPart:IsA("BasePart") then
			local cf = rootPart.CFrame
			pitch = -cf.RightVector:Dot(lookVector)

			if not inFirstPerson then
				dir = math.clamp(cf.LookVector:Dot(lookVector) * 10, -1, 1)
			end
		end

		yaw = lookVector.Y
	end

	if useDir then
		dir = useDir
	end

	pitch *= dir
	yaw *= dir

	return pitch, yaw
end
