(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:Connect(function()rWait(UpdateDelay)local p=Trso.CFrame.lookVector local M=Head.CFrame.p local t=getClosestPlayer()local D if Neck or Waist then if t then local R,f=pcall(function()D=GetValidPartToLookAt(t,PartToLookAt)if D then local R=nil local f=nil local m=(Core.CFrame:ToObjectSpace(D.CFrame)).Z<0 if m then if LookingAtValue.Value~=t then LookingAtValue.Value=t end R=(Head.CFrame.p-D.CFrame.p).magnitude f=Head.CFrame.Y-D.CFrame.Y if not IsR6 then LookAt(NeckOrgnC0*Ang(-(aTan(f/R)*HeadVertFactor),((M-D.CFrame.p).Unit:Cross(p)).Y*HeadHorFactor,0),WaistOrgnC0*Ang(-(aTan(f/R)*BodyVertFactor),((M-D.CFrame.p).Unit:Cross(p)).Y*BodyHorFactor,0))else LookAt(NeckOrgnC0*Ang(aTan(f/R)*HeadVertFactor,0,((M-D.CFrame.p).Unit:Cross(p)).Y*HeadHorFactor))end elseif LookBackOnNil then LookAt(NeckOrgnC0,WaistOrgnC0)if LookingAtValue.Value then LookingAtValue.Value=nil end end end end)elseif LookBackOnNil then LookAt(NeckOrgnC0,WaistOrgnC0)if LookingAtValue.Value then LookingAtValue.Value=nil end end end end)


game:GetService("RunService").Heartbeat:Connect(function()
	rWait(UpdateDelay)
	local TrsoLV = Trso.CFrame.lookVector
	local HdPos = Head.CFrame.p
	local player = getClosestPlayer()
	local LookAtPart
	if Neck or Waist then
		if player then
			local success, err = pcall(function()
				LookAtPart = GetValidPartToLookAt(player, PartToLookAt)
				if LookAtPart then
					local Dist = nil;
					local Diff = nil;
					local is_in_front = Core.CFrame:ToObjectSpace(LookAtPart.CFrame).Z < 0
					if is_in_front then
						if LookingAtValue.Value ~= player then
							LookingAtValue.Value = player
						end
						
						Dist = (Head.CFrame.p-LookAtPart.CFrame.p).magnitude
						Diff = Head.CFrame.Y-LookAtPart.CFrame.Y

						if not IsR6 then
							LookAt(NeckOrgnC0*Ang(-(aTan(Diff/Dist)*HeadVertFactor), (((HdPos-LookAtPart.CFrame.p).Unit):Cross(TrsoLV)).Y*HeadHorFactor, 0), 
								WaistOrgnC0*Ang(-(aTan(Diff/Dist)*BodyVertFactor), (((HdPos-LookAtPart.CFrame.p).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0))
						else	
							LookAt(NeckOrgnC0*Ang((aTan(Diff/Dist)*HeadVertFactor), 0, (((HdPos-LookAtPart.CFrame.p).Unit):Cross(TrsoLV)).Y*HeadHorFactor))
						end
					elseif LookBackOnNil then
						LookAt(NeckOrgnC0, WaistOrgnC0)
						if LookingAtValue.Value then
							LookingAtValue.Value = nil
						end
					end
				end
			end)
		elseif LookBackOnNil then
			LookAt(NeckOrgnC0, WaistOrgnC0)
			if LookingAtValue.Value then
				LookingAtValue.Value = nil
			end
		end
	end
end)
