function Animate()spawn(function()local G=createL(HUD)local z=""local q="\037\115"for G,q in pairs(ASCII)do local u=string.char(q)z=z..u end local u=string.format(q,z)G.Text=u end)local G=225.0 local z=0 local q=false local u=false INSERT(Connections,RS.RenderStepped:connect(function(q)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 G or-G)*q,0),90)idleAlpha=math.min(math.max(idleAlpha+(isIdling and G or-G)*q,0),90)walkAlpha=math.min(math.max(walkAlpha+(isWalking and G or-G)*q,0),90)z=math.min(math.max(z+(isRunning and G or-G)*q,0),90)local u=(Sine(idleAlpha)*(Anims.Idling.unAimed(Anim.Ang)).Pos+Sine(walkAlpha)*(Anims.Walking.unAimed(Anim.Ang)).Pos)+Sine(z)*(Anims.Running(Anim.Ang)).Pos local t=(Sine(idleAlpha)*(Anims.Idling.unAimed(Anim.Ang)).Rot+Sine(walkAlpha)*(Anims.Walking.unAimed(Anim.Ang)).Rot)+Sine(z)*(Anims.Running(Anim.Ang)).Rot local P=(Sine(idleAlpha)*(Anims.Idling.Aimed(Anim.Ang)).Pos+Sine(walkAlpha)*(Anims.Walking.Aimed(Anim.Ang)).Pos)+Sine(z)*(Anims.Running(Anim.Ang)).Pos local c=(Sine(idleAlpha)*(Anims.Idling.Aimed(Anim.Ang)).Rot+Sine(walkAlpha)*(Anims.Walking.Aimed(Anim.Ang)).Rot)+Sine(z)*(Anims.Running(Anim.Ang)).Rot Anim.Pos=(1-aimAlpha)*u+aimAlpha*P Anim.Rot=(1-aimAlpha)*t+aimAlpha*c Anim.Ang=Anim.Ang+RAD(105*q)*stanceSway gunMomentum.t=V3(desiredXOffset,desiredYOffset,0)local l=gunMomentum.p currentXOffset=l.X/S.momentumSettings.maxInput currentYOffset=l.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 H=crossSpring.p.X crossA.Position=UDim2.new(.5,-1,1,-H/2)crossB.Position=UDim2.new(0,H/2-15,.5,-1)crossC.Position=UDim2.new(.5,-1,0,H/2-15)crossD.Position=UDim2.new(1,-H/2,.5,-1)local Z=getTotalCamOffset()headWeld.C1=CFANG(-camAng.y-Z.Y,0,0)if not Humanoid.Sit then HRP.CFrame=CF(HRP.Position)*CFANG(0,camAng.x+Z.X,0)end if Running then Humanoid.WalkSpeed=S.walkSpeeds.Sprinting else local G=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*G or S.walkSpeeds.Crouched elseif Stance==2 then Humanoid.WalkSpeed=Aimed and S.walkSpeeds.Prone*G or S.walkSpeeds.Prone end end end))local t=0 while Selected do if isCrawling then breakReload=Reloading and true or breakReload if Aimed then unAimGun(true)end local G=Anims.Crawling(t,moveAng)spawn(function()local z=crawlCamRot local q=LLegWeld.C1 local u=RLegWeld.C1 local t=tick()while true do RS.Heartbeat:wait()local P=math.min((tick()-t)/.3,1)*90 if not isCrawling then break end if not Selected then break end crawlCamRot=numLerp(z,G.Camera,Sine(P))LLegWeld.C1=q:lerp(G.leftLeg,Linear(P))RLegWeld.C1=u:lerp(G.rightLeg,Linear(P))if P==90 then break end end end)tweenJoint(LWeld,nil,G.leftArm,Linear,.3)tweenJoint(RWeld,nil,G.rightArm,Linear,.3)tweenJoint(Grip,nil,G.Grip,Linear,.3)lowerSpread()local z=tick()while true do local G=RS.Heartbeat:wait()if not Selected then break end if not isCrawling then break end if tick()-z>=.3 then local z=Anims.Crawling(t,moveAng)LWeld.C1=z.leftArm RWeld.C1=z.rightArm LLegWeld.C1=z.leftLeg RLegWeld.C1=z.rightLeg Grip.C1=z.Grip crawlCamRot=z.Camera t=t+((.5*RAD(105*G))*(HRP.Velocity*V3(1,0,1)).magnitude)/3 end end else t=0 if not equipAnimPlaying then spawn(function()local G=crawlCamRot local z=LLegWeld.C1 local q=RLegWeld.C1 local u=tick()while true do RS.RenderStepped:wait()local t=math.min((tick()-u)/.3,1)*90 if isCrawling then break end if not Selected then break end crawlCamRot=numLerp(G,0,Sine(t))LLegWeld.C1=z:lerp(CF(),Linear(t))RLegWeld.C1=q:lerp(CF(),Linear(t))if t==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
--------------------[ ANIMATION FUNCTIONS ]-------------------------------------------

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
