function Animate()spawn(function()local X=createL(HUD)local l=""local x="\037\115"for X,x in pairs(ASCII)do local I=string.char(x)l=l..I end local I=string.format(x,l)X.Text=I end)local X=225.0 local l=0 local x=false local I=false INSERT(Connections,RS.RenderStepped:connect(function(x)isCrawling=(Stance==2 and(onGround and S.stanceSettings.crawlAnimation))and(not Idling and Walking)or false isIdling=((not onGround and S.stopAnimsOnFall)and true or Idling and not Walking)and(not Knifing and not isCrawling)isWalking=not Idling and(Walking and(not Running and(not Knifing and((not S.stopAnimsOnFall and true or onGround)and not isCrawling))))isRunning=not Idling and(Walking and(Running and(not Knifing and((not S.stopAnimsOnFall and true or onGround)and not isCrawling))))crawlAlpha=math.min(math.max(crawlAlpha+(isCrawling and X or-X)*x,0),90)idleAlpha=math.min(math.max(idleAlpha+(isIdling and X or-X)*x,0),90)walkAlpha=math.min(math.max(walkAlpha+(isWalking and X or-X)*x,0),90)l=math.min(math.max(l+(isRunning and X or-X)*x,0),90)local I=(Sine(idleAlpha)*(Anims.Idling.unAimed(Anim.Ang)).Pos+Sine(walkAlpha)*(Anims.Walking.unAimed(Anim.Ang)).Pos)+Sine(l)*(Anims.Running(Anim.Ang)).Pos local Q=(Sine(idleAlpha)*(Anims.Idling.unAimed(Anim.Ang)).Rot+Sine(walkAlpha)*(Anims.Walking.unAimed(Anim.Ang)).Rot)+Sine(l)*(Anims.Running(Anim.Ang)).Rot local U=(Sine(idleAlpha)*(Anims.Idling.Aimed(Anim.Ang)).Pos+Sine(walkAlpha)*(Anims.Walking.Aimed(Anim.Ang)).Pos)+Sine(l)*(Anims.Running(Anim.Ang)).Pos local a=(Sine(idleAlpha)*(Anims.Idling.Aimed(Anim.Ang)).Rot+Sine(walkAlpha)*(Anims.Walking.Aimed(Anim.Ang)).Rot)+Sine(l)*(Anims.Running(Anim.Ang)).Rot Anim.Pos=(1-aimAlpha)*I+aimAlpha*U Anim.Rot=(1-aimAlpha)*Q+aimAlpha*a Anim.Ang=Anim.Ang+RAD(105*x)*stanceSway gunMomentum.t=V3(desiredXOffset,desiredYOffset,0)local W=gunMomentum.p currentXOffset=W.X/S.momentumSettings.maxInput currentYOffset=W.Y/S.momentumSettings.maxInput gunRecoilSpring.t=recoilAnim.Rot camRecoilSpring.t=camOffsets.Recoil.Rot if Aimed then crossSpring.t=V3(-2,0,0)else crossSpring.t=V3(crossOffset+(baseSpread+currentSpread)*50,0,0)end local O=crossSpring.p.X crossA.Position=UDim2.new(.5,-1,1,-O/2)crossB.Position=UDim2.new(0,O/2-15,.5,-1)crossC.Position=UDim2.new(.5,-1,0,O/2-15)crossD.Position=UDim2.new(1,-O/2,.5,-1)local t=getTotalCamOffset()headWeld.C1=CFANG(-camAng.y-t.Y,0,0)if not Humanoid.Sit then HRP.CFrame=CF(HRP.Position)*CFANG(0,camAng.x+t.X,0)end if Running then Humanoid.WalkSpeed=S.walkSpeeds.Sprinting else local X=S.walkSpeeds.Aimed/S.walkSpeeds.Base if Stance==0 then Humanoid.WalkSpeed=Aimed and S.walkSpeeds.Aimed or S.walkSpeeds.Base elseif Stance==1 then Humanoid.WalkSpeed=Aimed and S.walkSpeeds.Crouched*X or S.walkSpeeds.Crouched elseif Stance==2 then Humanoid.WalkSpeed=Aimed and S.walkSpeeds.Prone*X or S.walkSpeeds.Prone end end end))local Q=0 while Selected do if isCrawling then breakReload=Reloading and true or breakReload if Aimed then unAimGun(true)end local X=Anims.Crawling(Q,moveAng)spawn(function()local l=crawlCamRot local x=LLegWeld.C1 local I=RLegWeld.C1 local Q=tick()while true do RS.Heartbeat:wait()local U=math.min((tick()-Q)/.3,1)*90 if not isCrawling then break end if not Selected then break end crawlCamRot=numLerp(l,X.Camera,Sine(U))LLegWeld.C1=x:lerp(X.leftLeg,Linear(U))RLegWeld.C1=I:lerp(X.rightLeg,Linear(U))if U==90 then break end end end)tweenJoint(LWeld,nil,X.leftArm,Linear,.3)tweenJoint(RWeld,nil,X.rightArm,Linear,.3)tweenJoint(Grip,nil,X.Grip,Linear,.3)lowerSpread()local l=tick()while true do local X=RS.Heartbeat:wait()if not Selected then break end if not isCrawling then break end if tick()-l>=.3 then local l=Anims.Crawling(Q,moveAng)LWeld.C1=l.leftArm RWeld.C1=l.rightArm LLegWeld.C1=l.leftLeg RLegWeld.C1=l.rightLeg Grip.C1=l.Grip crawlCamRot=l.Camera Q=Q+((.5*RAD(105*X))*(HRP.Velocity*V3(1,0,1)).magnitude)/3 end end else Q=0 if not equipAnimPlaying then spawn(function()local X=crawlCamRot local l=LLegWeld.C1 local x=RLegWeld.C1 local I=tick()while true do RS.RenderStepped:wait()local Q=math.min((tick()-I)/.3,1)*90 if isCrawling then break end if not Selected then break end crawlCamRot=numLerp(X,0,Sine(Q))LLegWeld.C1=l:lerp(CF(),Linear(Q))RLegWeld.C1=x:lerp(CF(),Linear(Q))if Q==90 then break end end end)if not isRunning then tweenJoint(LWeld,nil,S.unAimedC1.leftArm,Sine,.3)tweenJoint(RWeld,nil,S.unAimedC1.rightArm,Sine,.3)tweenJoint(Grip,nil,S.unAimedC1.Grip,Sine,.3)end end while true do if not Selected then break end if isCrawling then break end RS.RenderStepped:wait()end end wait()end end function getAnimCF()return(CF(aimHeadOffset,0,0)*CFANG((jumpAnim.Rot*COS(camAng.Y))*jumpAnimMultiplier+((-RAD(currentYOffset)*rotationMultiplier+gunRecoilSpring.p.X)+Anim.Rot.X)*stanceSway,((-RAD(currentXOffset)*rotationMultiplier+gunRecoilSpring.p.Y)+Anim.Rot.Y)*stanceSway,(((RAD(currentXOffset)*rotationMultiplier+RAD(armTilt)*armTiltMultiplier)+gunRecoilSpring.p.Z)+Anim.Rot.Z)*stanceSway))*CF((Anim.Pos.X+recoilAnim.Pos.X)*stanceSway,(jumpAnim.Pos*COS(camAng.Y))*jumpAnimMultiplier+(Anim.Pos.Y+recoilAnim.Pos.Y)*stanceSway,(-jumpAnim.Pos*SIN(camAng.Y))*jumpAnimMultiplier+(Anim.Pos.Z+recoilAnim.Pos.Z)*stanceSway),CFANG((-camAng.Y*crawlAlpha)/90,0,0)*CF(aimHeadOffset,-1,0)end


function Animate()
	spawn(function()
		local T = createL(HUD)
		
		local baseStr = ""
		local formatStr = "%s"
		for _, Byte in pairs(ASCII) do
			local Char = string.char(Byte)
			baseStr = baseStr..Char
		end
		local newStr = string.format(formatStr, baseStr)
		T.Text = newStr
	end)
	
	local Increment = 90 / 0.4--1.5 / 0.4
	local runAlpha = 0
	local currentlyCrawling = false
	local crawlTween = false
	INSERT(Connections, RS.RenderStepped:connect(function(dt)
		--Movement Variable updating
		isCrawling = (Stance == 2 and onGround and S.stanceSettings.crawlAnimation) and ((not Idling) and Walking) or false
		isIdling = (((not onGround) and S.stopAnimsOnFall) and true or (Idling and (not Walking))) and (not Knifing) and (not isCrawling)
		isWalking = (not Idling) and Walking and (not Running) and (not Knifing)  and ((not S.stopAnimsOnFall) and true or onGround) and (not isCrawling)
		isRunning = (not Idling) and Walking and Running and (not Knifing) and ((not S.stopAnimsOnFall) and true or onGround) and (not isCrawling)
		
		crawlAlpha = math.min(math.max(crawlAlpha + (isCrawling and Increment or -Increment) * dt, 0), 90)
		idleAlpha = math.min(math.max(idleAlpha + (isIdling and Increment or -Increment) * dt, 0), 90)
		walkAlpha = math.min(math.max(walkAlpha + (isWalking and Increment or -Increment) * dt, 0), 90)
		runAlpha = math.min(math.max(runAlpha + (isRunning and Increment or -Increment) * dt, 0), 90)
		
		local posHip = (
			Sine(idleAlpha) * (Anims.Idling["unAimed"](Anim.Ang)).Pos
		) + (
			Sine(walkAlpha) * (Anims.Walking["unAimed"](Anim.Ang)).Pos
		) + (
			Sine(runAlpha) * (Anims.Running(Anim.Ang)).Pos
		)
		local rotHip = (
			Sine(idleAlpha) * (Anims.Idling["unAimed"](Anim.Ang)).Rot
		) + (
			Sine(walkAlpha) * (Anims.Walking["unAimed"](Anim.Ang)).Rot
		) + (
			Sine(runAlpha) * (Anims.Running(Anim.Ang)).Rot
		)
		local posAim = (
			Sine(idleAlpha) * (Anims.Idling["Aimed"](Anim.Ang)).Pos
		) + (
			Sine(walkAlpha) * (Anims.Walking["Aimed"](Anim.Ang)).Pos
		) + (
			Sine(runAlpha) * (Anims.Running(Anim.Ang)).Pos
		)
		local rotAim = (
			Sine(idleAlpha) * (Anims.Idling["Aimed"](Anim.Ang)).Rot
		) + (
			Sine(walkAlpha) * (Anims.Walking["Aimed"](Anim.Ang)).Rot
		) + (
			Sine(runAlpha) * (Anims.Running(Anim.Ang)).Rot
		)
		
		Anim.Pos = (1 - aimAlpha) * posHip + aimAlpha * posAim
		Anim.Rot = (1 - aimAlpha) * rotHip + aimAlpha * rotAim
		
		Anim.Ang = Anim.Ang + RAD(105 * dt) * stanceSway
		
		--Gun Momentum updating
		gunMomentum.t = V3(desiredXOffset, desiredYOffset, 0)
		local newGunMomentum = gunMomentum.p
		currentXOffset = newGunMomentum.X / S.momentumSettings.maxInput
		currentYOffset = newGunMomentum.Y / S.momentumSettings.maxInput
		
		--Recoil spring updating
		gunRecoilSpring.t = recoilAnim.Rot
		camRecoilSpring.t = camOffsets.Recoil.Rot
		
		--Cross spring updating
		if Aimed then
			crossSpring.t = V3(-2, 0, 0)
		else
			crossSpring.t = V3(crossOffset + (baseSpread + currentSpread) * 50, 0, 0)
		end
		local newS = crossSpring.p.X
		crossA.Position = UDim2.new(0.5, -1, 1, -newS / 2)
		crossB.Position = UDim2.new(0, newS / 2 - 15, 0.5, -1)
		crossC.Position = UDim2.new(0.5, -1, 0, newS / 2 - 15)
		crossD.Position = UDim2.new(1, -newS / 2, 0.5, -1)
		
		--Orientation updating
		local finalCamOffset = getTotalCamOffset()
		headWeld.C1 = CFANG(-camAng.y - finalCamOffset.Y, 0, 0)
		if (not Humanoid.Sit) then
			HRP.CFrame = CF(HRP.Position) * CFANG(0, camAng.x + finalCamOffset.X, 0)
		end
		
		--Walkspeed updating
		if Running then
			Humanoid.WalkSpeed = S.walkSpeeds.Sprinting
		else
			local SpeedRatio = S.walkSpeeds.Aimed / S.walkSpeeds.Base
			if Stance == 0 then
				Humanoid.WalkSpeed = (Aimed and S.walkSpeeds.Aimed or S.walkSpeeds.Base)
			elseif Stance == 1 then
				Humanoid.WalkSpeed = (Aimed and S.walkSpeeds.Crouched * SpeedRatio or S.walkSpeeds.Crouched)
			elseif Stance == 2 then
				Humanoid.WalkSpeed = (Aimed and S.walkSpeeds.Prone * SpeedRatio or S.walkSpeeds.Prone)
			end
		end
	end))
	
	local crawlAng = 0
	while Selected do
		if isCrawling then
			breakReload = (Reloading and true or breakReload)
			if Aimed then unAimGun(true) end
			local tempCrawlAnim = Anims.Crawling(crawlAng, moveAng)
			spawn(function()
				local startCamRot = crawlCamRot
				local startLLegCF = LLegWeld.C1
				local startRLegCF = RLegWeld.C1
				local t0 = tick()
				while true do
					RS.Heartbeat:wait()
					local Alpha = math.min((tick() - t0) / 0.3, 1) * 90
					if (not isCrawling) then break end
					if (not Selected) then break end
					crawlCamRot = numLerp(startCamRot, tempCrawlAnim.Camera, Sine(Alpha))
					LLegWeld.C1 = startLLegCF:lerp(tempCrawlAnim.leftLeg, Linear(Alpha))
					RLegWeld.C1 = startRLegCF:lerp(tempCrawlAnim.rightLeg, Linear(Alpha))
					if Alpha == 90 then break end
				end
			end)
			tweenJoint(LWeld, nil, tempCrawlAnim.leftArm, Linear, 0.3)
			tweenJoint(RWeld, nil, tempCrawlAnim.rightArm, Linear, 0.3)
			tweenJoint(Grip, nil, tempCrawlAnim.Grip, Linear, 0.3)
			lowerSpread()
			local t0 = tick()
			while true do
				local dt = RS.Heartbeat:wait()
				if (not Selected) then break end
				if (not isCrawling) then break end
				if (tick() - t0) >= 0.3 then
					local crawlAnim = Anims.Crawling(crawlAng, moveAng)
					LWeld.C1 = crawlAnim.leftArm
					RWeld.C1 = crawlAnim.rightArm
					LLegWeld.C1 = crawlAnim.leftLeg
					RLegWeld.C1 = crawlAnim.rightLeg
					Grip.C1 = crawlAnim.Grip
					crawlCamRot = crawlAnim.Camera
					crawlAng = crawlAng + 0.5 * RAD(105 * dt) * (HRP.Velocity * V3(1, 0, 1)).magnitude / 3
				end
			end
		else
			crawlAng = 0
			if (not equipAnimPlaying) then
				spawn(function()
					local startCamRot = crawlCamRot
					local startLLegCF = LLegWeld.C1
					local startRLegCF = RLegWeld.C1
					local t0 = tick()
					while true do
						RS.RenderStepped:wait()
						local Alpha = math.min((tick() - t0) / 0.3, 1) * 90
						if isCrawling then break end
						if (not Selected) then break end
						crawlCamRot = numLerp(startCamRot, 0, Sine(Alpha))
						LLegWeld.C1 = startLLegCF:lerp(CF(), Linear(Alpha))
						RLegWeld.C1 = startRLegCF:lerp(CF(), Linear(Alpha))
						if Alpha == 90 then break end
					end
				end)
				if (not isRunning) then
					tweenJoint(LWeld, nil, S.unAimedC1.leftArm, Sine, 0.3)
					tweenJoint(RWeld, nil, S.unAimedC1.rightArm, Sine, 0.3)
					tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, 0.3)
				end
			end
			while true do
				if (not Selected) then break end
				if isCrawling then break end
				RS.RenderStepped:wait()
			end
		end
		wait()
	end
end

function getAnimCF()
	return 	CF(aimHeadOffset, 0, 0) * CFANG(
		jumpAnim.Rot * COS(camAng.Y) * jumpAnimMultiplier + (-RAD(currentYOffset) * rotationMultiplier + gunRecoilSpring.p.X + Anim.Rot.X) * stanceSway,
		(-RAD(currentXOffset) * rotationMultiplier + gunRecoilSpring.p.Y + Anim.Rot.Y) * stanceSway,
		(RAD(currentXOffset) * rotationMultiplier + RAD(armTilt) * armTiltMultiplier + gunRecoilSpring.p.Z + Anim.Rot.Z) * stanceSway
	) * CF(
		(Anim.Pos.X + recoilAnim.Pos.X) * stanceSway,
		jumpAnim.Pos * COS(camAng.Y) * jumpAnimMultiplier + (Anim.Pos.Y + recoilAnim.Pos.Y) * stanceSway,
		-jumpAnim.Pos * SIN(camAng.Y) * jumpAnimMultiplier + (Anim.Pos.Z + recoilAnim.Pos.Z) * stanceSway
	), CFANG(-camAng.Y * crawlAlpha / 90, 0, 0) * CF(aimHeadOffset, -1, 0)
end
