local p={0,0;0,0;0}local W=function(p,W)if p~="\082\117\110\110\105\110\103"then if not Aimed then if p=="\073\100\108\101\105\110\103"then return CF((RAD(SIN(W))/2)*StanceSway,1+(RAD(SIN((W*5)/2))/2)*StanceSway,0)elseif p=="\087\097\108\107\105\110\103"then return CF((RAD(SIN(W))*3)*StanceSway,1+(RAD(ABS(SIN(W)))*-3)*StanceSway,RAD(ABS(SIN(W))))*CFANG(0,RAD(SIN(W))/5,RAD(SIN(W)))end elseif Aimed then if p=="\073\100\108\101\105\110\103"then return CF((RAD(SIN(W))/4)*StanceSway,1+(RAD(SIN((W*5)/2))/4)*StanceSway,0)elseif p=="\087\097\108\107\105\110\103"then return CF((RAD(SIN(W))*1.5)*StanceSway,1+(RAD(ABS(SIN(W)))*-1.5)*StanceSway,RAD(ABS(SIN(W))))*CFANG(0,RAD(SIN(W))/5,RAD(SIN(W)))end end elseif p=="\082\117\110\110\105\110\103"then return CF((SIN(W)/5.25)*StanceSway,.775+(ABS(SIN(W))/-14.5)*StanceSway,RAD((SIN(W)*-6.5)*StanceSway+-1.2))*CFANG(RAD((SIN(W)*4.5)*StanceSway),RAD(SIN(W)*-8.5),RAD((SIN(W)*1)*StanceSway))end end function Animate()local a=false local w=false local U=false spawn(function()while Selected do a=Idleing and(not Walking and(not Reloading and(not Knifing and Selected)))w=not Idleing and(Walking and(not Running and(not Reloading and(not Knifing and Selected))))U=not Idleing and(Walking and(Running and(not Aiming and(not Knifing and Selected))))RS:wait()end a=false w=false U=false end)spawn(function()if S.PlayerAnimations then TweenJoint(LWeld2,CF(),CFANG(0,RAD(ArmTilt),0),Sine,.15)TweenJoint(RWeld2,CF(),CFANG(0,RAD(ArmTilt),0),Sine,.15)local p=ArmTilt while Selected do repeat RS:wait()until ArmTilt~=p if not U and(not Aimed and(not Reloading and(not Knifing and Selected)))then p=ArmTilt TweenJoint(LWeld2,CF(),CFANG(0,RAD(ArmTilt),0),Sine,.15)TweenJoint(RWeld2,CF(),CFANG(0,RAD(ArmTilt),0),Sine,.15)end RS:wait()end end end)spawn(function()while Selected do if a then if not Aimed and not Aiming then Gui_Clone.CrossHair.Box:TweenSizeAndPosition(UDim2.new(0,70,0,70),UDim2.new(0,-35,0,-35),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,S.PlayerAnimations and.15 or 0,true)if S.PlayerAnimations then TweenJoint(LWeld,ArmC0[1],S.ArmC1_UnAimed.Left,Sine,.15)TweenJoint(RWeld,ArmC0[2],S.ArmC1_UnAimed.Right,Sine,.15)TweenJoint(AnimWeld,W("\073\100\108\101\105\110\103",p[1]),CF(),Sine,.15)TweenJoint(Grip,Grip.C0,CFANG(0,RAD(20),0),Sine,.15)else if not LWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not RWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not ABWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and not AnimWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")))then LWeld.C0,LWeld.C1=ArmC0[1],S.ArmC1_UnAimed.Left RWeld.C0,RWeld.C1=ArmC0[2],S.ArmC1_UnAimed.Right AnimWeld.C0=CF(0,1,0)Grip.C1=CFANG(0,RAD(20),0)end end elseif Aimed and not Aiming then if S.PlayerAnimations then TweenJoint(LWeld,ArmC0[1],S.ArmC1_Aimed.Left,Sine,.15)TweenJoint(RWeld,ArmC0[2],S.ArmC1_Aimed.Right,Sine,.15)TweenJoint(AnimWeld,W("\073\100\108\101\105\110\103",p[2]),CF(),Sine,.15)else if not LWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not RWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not ABWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and not AnimWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")))then LWeld.C0,LWeld.C1=ArmC0[1],S.ArmC1_Aimed.Left RWeld.C0,RWeld.C1=ArmC0[2],S.ArmC1_Aimed.Right AnimWeld.C0=CF(0,1,0)Grip.C1=Aimed_GripCF end end end if S.PlayerAnimations then wait(.15)RunTween=false while a do if not LWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not RWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not ABWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and not AnimWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")))then if not Aimed and not Aiming then AnimWeld.C0=W("\073\100\108\101\105\110\103",p[1])p[1]=p[1]+.03*StanceSway elseif Aimed and not Aiming then AnimWeld.C0=W("\073\100\108\101\105\110\103",p[2])p[2]=p[2]+.015*StanceSway end end RS:wait()end p[1],p[2]=0,0 end end if w then if not Aimed and not Aiming then Gui_Clone.CrossHair.Box:TweenSizeAndPosition(UDim2.new(0,150,0,150),UDim2.new(0,-75,0,-75),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,S.PlayerAnimations and.15 or 0,true)if S.PlayerAnimations then TweenJoint(LWeld,ArmC0[1],S.ArmC1_UnAimed.Left,Sine,.15)TweenJoint(RWeld,ArmC0[2],S.ArmC1_UnAimed.Right,Sine,.15)TweenJoint(AnimWeld,W("\087\097\108\107\105\110\103",p[3]),CF(),Sine,.15)TweenJoint(Grip,Grip.C0,CFANG(0,RAD(20),0),Sine,.15)else if not LWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not RWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not ABWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and not AnimWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")))then LWeld.C0,LWeld.C1=ArmC0[1],S.ArmC1_UnAimed.Left RWeld.C0,RWeld.C1=ArmC0[2],S.ArmC1_UnAimed.Right AnimWeld.C0=CF(0,1,0)Grip.C1=CFANG(0,RAD(20),0)end end elseif Aimed and not Aiming then if S.PlayerAnimations then TweenJoint(LWeld,ArmC0[1],S.ArmC1_Aimed.Left,Sine,.15)TweenJoint(RWeld,ArmC0[2],S.ArmC1_Aimed.Right,Sine,.15)TweenJoint(AnimWeld,W("\087\097\108\107\105\110\103",p[4]),CF(),Sine,.15)else if not LWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not RWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not ABWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and not AnimWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")))then LWeld.C0,LWeld.C1=ArmC0[1],S.ArmC1_Aimed.Left RWeld.C0,RWeld.C1=ArmC0[2],S.ArmC1_Aimed.Right AnimWeld.C0=CF(0,1,0)Grip.C1=Aimed_GripCF end end end if S.PlayerAnimations then wait(.15)RunTween=false while w do if not LWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not RWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and(not ABWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")and not AnimWeld:FindFirstChild("\084\119\101\101\110\067\111\100\101")))then if not Aimed and not Aiming then AnimWeld.C0=W("\087\097\108\107\105\110\103",p[3])p[3]=p[3]+.15*StanceSway elseif Aimed and not Aiming then AnimWeld.C0=W("\087\097\108\107\105\110\103",p[4])p[4]=p[4]+.1*StanceSway end end RS:wait()end p[3],p[4]=0,0 end end if U then Gui_Clone.CrossHair.Box:TweenSizeAndPosition(UDim2.new(0,200,0,200),UDim2.new(0,-100,0,-100),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,S.PlayerAnimations and.15 or 0,true)local a=CF(-0.2,.85-(SIN(p[5])+1)/15,-0.6)local w=CFANG(RAD(ABS(COS(p[5])))*10+RAD(15),RAD(-15),RAD(-15))local X=CF(0,(SIN(p[5])+1)/2,-0.5)local O=CFANG(RAD(ABS(COS(p[5])))*10+RAD(10),0,RAD(50+(SIN(p[5])+1)*5))if S.PlayerAnimations then Camera.FieldOfView=90 TweenJoint(LWeld,ArmC0[1],a*w,Sine,1.15)TweenJoint(RWeld,ArmC0[2],X*O,Sine,1.15)TweenJoint(AnimWeld,W("\082\117\110\110\105\110\103",p[5]),CF(),Sine,.15)TweenJoint(Grip,Grip.C0,CFANG(0,RAD(-5),0),Sine,1.15)else LWeld.C0,LWeld.C1=ArmC0[1],a*w RWeld.C0,RWeld.C1=ArmC0[2],X*O AnimWeld.C0=CF(0,.9,0)Grip.C1=CFANG(0,RAD(-5),0)end if S.PlayerAnimations then RunTween=true wait(.15)while U do if not Aiming then AnimWeld.C0=W("\082\117\110\110\105\110\103",p[5])p[5]=p[5]+.18 end RS:wait()end Camera.FieldOfView=90 p[5]=0 end end RS:wait()end end)end


local AnimAng = {0, 0, 0, 0, 0}

local AnimCF = function(State, Ang)
	if State ~= "Running" then
		if (not Aimed) then
			if State == "Idleing" then
				return CF(
					RAD(SIN(Ang)) / 2 * StanceSway,
					1 + RAD(SIN(Ang * 5 / 2)) / 2 * StanceSway, 0
				)
			elseif State == "Walking" then
				return CF(
					RAD(SIN(Ang)) * 3 * StanceSway,
					1 + RAD(ABS(SIN(Ang))) * -3 * StanceSway, RAD(ABS(SIN(Ang)))
				) * CFANG(0, RAD(SIN(Ang)) / 5, RAD(SIN(Ang)))
			end
		elseif Aimed then
			if State == "Idleing" then
				return CF(
					RAD(SIN(Ang)) / 4 * StanceSway,
					1 + RAD(SIN(Ang * 5 / 2)) / 4 * StanceSway, 0
				)
			elseif State == "Walking" then
				return CF(
					RAD(SIN(Ang)) * 1.5 * StanceSway,
					1 + RAD(ABS(SIN(Ang))) * -1.5 * StanceSway, RAD(ABS(SIN(Ang)))
				) * CFANG(0, RAD(SIN(Ang)) / 5, RAD(SIN(Ang)))
			end
		end
	elseif State == "Running" then
		return CF(
			SIN(Ang) / 5.25 * StanceSway,
			0.775 + ABS(SIN(Ang)) / -14.5 * StanceSway, RAD(SIN(Ang)* -6.5 * StanceSway + -1.2)
		) * CFANG(RAD(SIN(Ang)* 4.5 * StanceSway), RAD(SIN(Ang)* -8.5 ), RAD(SIN(Ang)* 1 * StanceSway))
	end
end

function Animate()
	local IsIdleing = false
	local IsWalking = false
	local IsRunning = false
	spawn(function()
		while Selected do
			IsIdleing = Idleing and (not Walking) and (not Reloading) and (not Knifing) and Selected
			IsWalking = (not Idleing) and Walking and (not Running) and (not Reloading) and (not Knifing) and Selected
			IsRunning = (not Idleing) and Walking and Running and (not Aiming) and (not Knifing) and Selected
			RS:wait()
		end
		IsIdleing = false
		IsWalking = false
		IsRunning = false
	end)
	spawn(function()
		if S.PlayerAnimations then
			TweenJoint(LWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
			TweenJoint(RWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
			local PreviousArmTilt = ArmTilt
			while Selected do
				repeat RS:wait() until ArmTilt ~= PreviousArmTilt
				if (not IsRunning) and (not Aimed) and (not Reloading) and (not Knifing) and Selected then
					PreviousArmTilt = ArmTilt
					TweenJoint(LWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
					TweenJoint(RWeld2, CF(), CFANG(0, RAD(ArmTilt), 0), Sine, 0.15)
				end
				RS:wait()
			end
		end
	end)
	spawn(function()
		while Selected do
			if IsIdleing then
				if (not Aimed) and (not Aiming) then
					Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
						UDim2.new(0, 70, 0, 70),
						UDim2.new(0, -35, 0, -35),
						Enum.EasingDirection.Out,
						Enum.EasingStyle.Linear,
						S.PlayerAnimations and 0.15 or 0,
						true
					)
					if S.PlayerAnimations then
						TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, 0.15)
						TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, 0.15)
						TweenJoint(AnimWeld, AnimCF("Idleing", AnimAng[1]), CF(), Sine, 0.15)
						TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, 0.15)
					else
						if (not LWeld:FindFirstChild("TweenCode"))
						and (not RWeld:FindFirstChild("TweenCode"))
						and (not ABWeld:FindFirstChild("TweenCode"))
						and (not AnimWeld:FindFirstChild("TweenCode")) then
							LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_UnAimed.Left
							RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_UnAimed.Right
							AnimWeld.C0 = CF(0, 1, 0)
							Grip.C1 = CFANG(0, RAD(20), 0)
						end
					end
				elseif Aimed and (not Aiming) then
					if S.PlayerAnimations then
						TweenJoint(LWeld, ArmC0[1], S.ArmC1_Aimed.Left, Sine, 0.15)
						TweenJoint(RWeld, ArmC0[2], S.ArmC1_Aimed.Right, Sine, 0.15)
						TweenJoint(AnimWeld, AnimCF("Idleing", AnimAng[2]), CF(), Sine, 0.15)
					else
						if (not LWeld:FindFirstChild("TweenCode"))
						and (not RWeld:FindFirstChild("TweenCode"))
						and (not ABWeld:FindFirstChild("TweenCode"))
						and (not AnimWeld:FindFirstChild("TweenCode")) then
							LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_Aimed.Left
							RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_Aimed.Right
							AnimWeld.C0 = CF(0, 1, 0)
							Grip.C1 = Aimed_GripCF
						end
					end
				end
				if S.PlayerAnimations then
					wait(0.15)
					RunTween = false
					while IsIdleing do
						if (not LWeld:FindFirstChild("TweenCode"))
						and (not RWeld:FindFirstChild("TweenCode"))
						and (not ABWeld:FindFirstChild("TweenCode"))
						and (not AnimWeld:FindFirstChild("TweenCode")) then
							if (not Aimed) and (not Aiming) then
								AnimWeld.C0 = AnimCF("Idleing", AnimAng[1])
								AnimAng[1] = AnimAng[1] + 0.03 * StanceSway
							elseif Aimed and (not Aiming) then
								AnimWeld.C0 = AnimCF("Idleing", AnimAng[2])
								AnimAng[2] = AnimAng[2] + 0.015 * StanceSway
							end
						end
						RS:wait()
					end
					AnimAng[1], AnimAng[2] = 0, 0
				end
			end
			if IsWalking then
				if (not Aimed) and (not Aiming) then
					Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
						UDim2.new(0, 150, 0, 150),
						UDim2.new(0, -75, 0, -75),
						Enum.EasingDirection.Out,
						Enum.EasingStyle.Linear,
						S.PlayerAnimations and 0.15 or 0,
						true
					)
					if S.PlayerAnimations then
						TweenJoint(LWeld, ArmC0[1], S.ArmC1_UnAimed.Left, Sine, 0.15)
						TweenJoint(RWeld, ArmC0[2], S.ArmC1_UnAimed.Right, Sine, 0.15)
						TweenJoint(AnimWeld, AnimCF("Walking", AnimAng[3]), CF(), Sine, 0.15)
						TweenJoint(Grip, Grip.C0, CFANG(0, RAD(20), 0), Sine, 0.15)
					else
						if (not LWeld:FindFirstChild("TweenCode"))
						and (not RWeld:FindFirstChild("TweenCode"))
						and (not ABWeld:FindFirstChild("TweenCode"))
						and (not AnimWeld:FindFirstChild("TweenCode")) then
							LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_UnAimed.Left
							RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_UnAimed.Right
							AnimWeld.C0 = CF(0, 1, 0)
							Grip.C1 = CFANG(0, RAD(20), 0)
						end
					end
				elseif Aimed and (not Aiming) then
					if S.PlayerAnimations then
						TweenJoint(LWeld, ArmC0[1], S.ArmC1_Aimed.Left, Sine, 0.15)
						TweenJoint(RWeld, ArmC0[2], S.ArmC1_Aimed.Right, Sine, 0.15)
						TweenJoint(AnimWeld, AnimCF("Walking", AnimAng[4]), CF(), Sine, 0.15)
					else
						if (not LWeld:FindFirstChild("TweenCode"))
						and (not RWeld:FindFirstChild("TweenCode"))
						and (not ABWeld:FindFirstChild("TweenCode"))
						and (not AnimWeld:FindFirstChild("TweenCode")) then
							LWeld.C0, LWeld.C1 = ArmC0[1], S.ArmC1_Aimed.Left
							RWeld.C0, RWeld.C1 = ArmC0[2], S.ArmC1_Aimed.Right
							AnimWeld.C0 = CF(0, 1, 0)
							Grip.C1 = Aimed_GripCF
						end
					end
				end
				if S.PlayerAnimations then
					wait(0.15)
					RunTween = false
					while IsWalking do
						if (not LWeld:FindFirstChild("TweenCode"))
						and (not RWeld:FindFirstChild("TweenCode"))
						and (not ABWeld:FindFirstChild("TweenCode"))
						and (not AnimWeld:FindFirstChild("TweenCode"))then
							if (not Aimed) and (not Aiming) then
								AnimWeld.C0 = AnimCF("Walking", AnimAng[3])
								AnimAng[3] = AnimAng[3] + 0.15 * StanceSway
							elseif Aimed and (not Aiming) then
								AnimWeld.C0 = AnimCF("Walking", AnimAng[4])
								AnimAng[4] = AnimAng[4] + 0.1 * StanceSway
							end
						end
						RS:wait()
					end
					AnimAng[3], AnimAng[4] = 0, 0
				end
			end
			if IsRunning then
				Gui_Clone.CrossHair.Box:TweenSizeAndPosition(
					UDim2.new(0, 200, 0, 200),
					UDim2.new(0, -100, 0, -100),
					Enum.EasingDirection.Out,
					Enum.EasingStyle.Linear,
					S.PlayerAnimations and 0.15 or 0,
					true
				)
				local LArmCF = CF(-.2, .85 - (SIN(AnimAng[5]) + 1)/15, -0.6)
				local LArmAng = CFANG(RAD(ABS(COS(AnimAng[5]))) * 10 + RAD(15), RAD(-15), RAD(-15))
				local RArmCF = CF(0, (SIN(AnimAng[5]) + 1)/2, -0.5)
				local RArmAng = CFANG(RAD(ABS(COS(AnimAng[5]))) * 10 + RAD(10), 0, RAD(50 + (SIN(AnimAng[5]) + 1) * 5))
				if S.PlayerAnimations then
					Camera.FieldOfView = 90
					TweenJoint(LWeld, ArmC0[1], LArmCF * LArmAng, Sine, 1.15)
					TweenJoint(RWeld, ArmC0[2], RArmCF * RArmAng, Sine, 1.15)
					TweenJoint(AnimWeld, AnimCF("Running", AnimAng[5]), CF(), Sine, 0.15)
					TweenJoint(Grip, Grip.C0, CFANG(0, RAD(-5), 0), Sine, 1.15)
				else
					LWeld.C0, LWeld.C1 = ArmC0[1], LArmCF * LArmAng
					RWeld.C0, RWeld.C1 = ArmC0[2], RArmCF * RArmAng
					AnimWeld.C0 = CF(0, 0.9, 0)
					Grip.C1 = CFANG(0, RAD(-5), 0)
				end
				if S.PlayerAnimations then
					RunTween = true
					wait(0.15)
					while IsRunning do
						if (not Aiming) then
							AnimWeld.C0 = AnimCF("Running", AnimAng[5])
							AnimAng[5] = AnimAng[5] + 0.18
						end
						RS:wait()
					end
					Camera.FieldOfView = 90	
					AnimAng[5] = 0
				end
			end
			RS:wait()
		end						
	end)
end
