function aimGun()if Reloading or Knifing or isCrawling or not S.canADS then return end mouseSensitivity=aimSensitivity for j,I in pairs(Plugins.Aimed)do spawn(function()I()end)end Aimed=true Aiming=true Running=false spreadZoom="\065\105\109\101\100"baseSpread=S.spreadSettings[spreadZoom][spreadStance][spreadMotion]if S.aimSettings.Anim then local j=Cam.FieldOfView local I=Scope.BackgroundTransparency tweenJoint(LWeld,armC0[1],S.aimedC1.leftArm,Sine,S.aimSettings.Speed)tweenJoint(RWeld,armC0[2],S.aimedC1.rightArm,Sine,S.aimSettings.Speed)tweenJoint(LWeld2,nil,CF(),Sine,S.aimSettings.Speed)tweenJoint(RWeld2,nil,CF(),Sine,S.aimSettings.Speed)tweenJoint(Grip,nil,aimedGripCF,Sine,S.aimSettings.Speed)tweenJoint(headWeld2,nil,(CF(0,-0.5,0)*CFANG(0,0,S.aimSettings.headTilt))*CF(0,.5,0),Sine,S.aimSettings.Speed)local O=tick()while true do RS.RenderStepped:wait()local w=math.min((tick()-O)/S.aimSettings.Speed,1)*90 if not Aimed then break end if not Selected then break end aimAlpha=Sine(w)aimHeadOffset=headOffset.X*aimAlpha jumpAnimMultiplier=numLerp(1,S.fallSettings.aimEffect,aimAlpha)translationDivisor=numLerp(7,20,aimAlpha)rotationMultiplier=numLerp(S.momentumSettings.Amplitude.unAimed,S.momentumSettings.Amplitude.Aimed,aimAlpha)armTiltMultiplier=numLerp(1,.2,aimAlpha)Cam.FieldOfView=numLerp(j,S.aimSettings.FOV,aimAlpha)if S.guiScope then Scope.BackgroundTransparency=numLerp(I,0,aimAlpha)end if w==90 then break end end else LWeld.C0,LWeld.C1=armC0[1],S.aimedC1.leftArm RWeld.C0,RWeld.C1=armC0[2],S.aimedC1.rightArm LWeld2.C1,RWeld2.C1=CF(),CF()animWeld.C0=CF(0,1,0)Grip.C1=aimedGripCF headWeld2.C1=(CF(0,-0.5,0)*CFANG(0,0,S.aimSettings.headTilt))*CF(0,.5,0)aimAlpha=1 aimHeadOffset=headOffset.X jumpAnimMultiplier=S.fallSettings.aimEffect translationDivisor=20 rotationMultiplier=S.momentumSettings.Amplitude.Aimed armTiltMultiplier=.2 Cam.FieldOfView=S.aimSettings.FOV end Aiming=not Aimed if not Aiming and S.guiScope then spawn(function()scopeSteady.Visible=true Scope.BackgroundTransparency=1 scopeMain.Visible=true if armTable then for j,I in pairs(armTable[1].Model:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=1 end end for j,I in pairs(armTable[2].Model:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=1 end end elseif armModel then for j,I in pairs(armModel:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=1 end end end for j,I in pairs(playerFolder:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=1 end end for j,I in pairs(Gun:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=1 end end end)spawn(function()local j=0 local I=function()return V3(((RAD(SIN(j*S.scopeSettings.Frequency.Idling))*stanceSway)*camSway)*S.scopeSettings.Amplitude.Idling,(((RAD(SIN(((j*5)/2)*S.scopeSettings.Frequency.Idling))*stanceSway)*camSway)*S.scopeSettings.Amplitude.Idling)*.75,0)end local O=function()return V3(((RAD(SIN(j*S.scopeSettings.Frequency.Walking))*camSway)*stanceSway)*S.scopeSettings.Amplitude.Walking,(((RAD(SIN(((j*5)/2)*S.scopeSettings.Frequency.Walking))*camSway)*stanceSway)*S.scopeSettings.Amplitude.Walking)*.75,0)end while Aimed do local w=RS.RenderStepped:wait()camOffsets.guiScope.Rot=Sine(idleAlpha)*I()+Sine(walkAlpha)*O()j=j+(RAD(105*w)*stanceSway)*camSway end end)end end function unAimGun(j)if not S.canADS then return end mouseSensitivity=S.sensitivitySettings.Default for j,I in pairs(Plugins.UnAimed)do spawn(function()I()end)end if S.guiScope then spawn(function()if armTable then for j,I in pairs(armTable[1].Model:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=0 end end for j,I in pairs(armTable[2].Model:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=0 end end elseif armModel then for j,I in pairs(armModel:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=0 end end end for j,I in pairs(playerFolder:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=0 end end for j,I in pairs(Gun:GetChildren())do if I:IsA("\066\097\115\101\080\097\114\116")then I.LocalTransparencyModifier=0 end end end)end if not j then if not Aimed then return end if Reloading and j or Knifing then return end spreadZoom="\117\110\065\105\109\101\100"baseSpread=S.spreadSettings[spreadZoom][spreadStance][spreadMotion]Aimed=false Aiming=true if S.aimSettings.Anim then local j=Cam.FieldOfView local I=Scope.BackgroundTransparency==1 and(S.guiScope and 0 or 1)or Scope.BackgroundTransparency scopeMain.Visible=false scopeSteady.Visible=false tweenJoint(LWeld,armC0[1],S.unAimedC1.leftArm,Sine,S.aimSettings.Speed)tweenJoint(RWeld,armC0[2],S.unAimedC1.rightArm,Sine,S.aimSettings.Speed)tweenJoint(headWeld2,nil,CF(),Sine,S.aimSettings.Speed)tweenJoint(Grip,nil,S.unAimedC1.Grip,Sine,S.aimSettings.Speed)local O=tick()while true do RS.RenderStepped:wait()local w=math.min((tick()-O)/S.aimSettings.Speed,1)*90 if Aimed then break end if not Selected then break end aimAlpha=1-Sine(w)aimHeadOffset=headOffset.X*aimAlpha jumpAnimMultiplier=numLerp(1,S.fallSettings.aimEffect,aimAlpha)translationDivisor=numLerp(7,20,aimAlpha)rotationMultiplier=numLerp(S.momentumSettings.Amplitude.unAimed,S.momentumSettings.Amplitude.Aimed,aimAlpha)armTiltMultiplier=numLerp(1,.2,aimAlpha)Cam.FieldOfView=numLerp(80,j,aimAlpha)Scope.BackgroundTransparency=numLerp(1,I,aimAlpha)if w==90 then break end end else scopeMain.Visible=false scopeSteady.Visible=false LWeld.C0,LWeld.C1=armC0[1],S.unAimedC1.leftArm RWeld.C0,RWeld.C1=armC0[2],S.unAimedC1.rightArm headWeld2.C0=CF()Grip.C1=S.unAimedC1.Grip aimAlpha=0 aimHeadOffset=0 jumpAnimMultiplier=1 translationDivisor=7 rotationMultiplier=S.momentumSettings.Amplitude.unAimed armTiltMultiplier=1 Cam.FieldOfView=80 Scope.BackgroundTransparency=1 end Aiming=Aimed else spawn(function()Aimed=false Aiming=false spreadZoom="\117\110\065\105\109\101\100"baseSpread=S.spreadSettings[spreadZoom][spreadStance][spreadMotion]local j=Cam.FieldOfView local I=Scope.BackgroundTransparency==1 and(S.guiScope and 0 or 1)or Scope.BackgroundTransparency scopeMain.Visible=false scopeSteady.Visible=false tweenJoint(headWeld2,nil,CF(),Sine,S.aimSettings.Speed)if S.aimSettings.Anim then local O=tick()while true do RS.RenderStepped:wait()local w=math.min((tick()-O)/S.aimSettings.Speed,1)*90 if Aimed then break end if not Selected then break end aimAlpha=1-Sine(w)aimHeadOffset=headOffset.X*aimAlpha jumpAnimMultiplier=numLerp(1,S.fallSettings.aimEffect,aimAlpha)translationDivisor=numLerp(7,20,aimAlpha)rotationMultiplier=numLerp(S.momentumSettings.Amplitude.unAimed,S.momentumSettings.Amplitude.Aimed,aimAlpha)armTiltMultiplier=numLerp(1,.2,aimAlpha)Cam.FieldOfView=numLerp(80,j,aimAlpha)Scope.BackgroundTransparency=numLerp(1,I,aimAlpha)if w==90 then break end end else scopeMain.Visible=false scopeSteady.Visible=false aimAlpha=0 aimHeadOffset=0 jumpAnimMultiplier=1 translationDivisor=7 rotationMultiplier=S.momentumSettings.Amplitude.unAimed armTiltMultiplier=1 Cam.FieldOfView=80 Scope.BackgroundTransparency=1 end end)end end


function aimGun()
	if Reloading or Knifing or isCrawling or (not S.canADS) then return end
	
	mouseSensitivity = aimSensitivity
	
	for _, Plugin in pairs(Plugins.Aimed) do
		spawn(function()
			Plugin()
		end)
	end
	
	Aimed = true
	Aiming = true
	Running = false
	spreadZoom = "Aimed"
	baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
	if S.aimSettings.Anim then
		local currentFOV = Cam.FieldOfView
		local currentTrans = Scope.BackgroundTransparency
		tweenJoint(LWeld, armC0[1], S.aimedC1.leftArm, Sine, S.aimSettings.Speed)
		tweenJoint(RWeld, armC0[2], S.aimedC1.rightArm, Sine, S.aimSettings.Speed)
		tweenJoint(LWeld2, nil, CF(), Sine, S.aimSettings.Speed)
		tweenJoint(RWeld2, nil, CF(), Sine, S.aimSettings.Speed)
		tweenJoint(Grip, nil, aimedGripCF, Sine, S.aimSettings.Speed)
		tweenJoint(headWeld2, nil, CF(0, -0.5, 0) * CFANG(0, 0, S.aimSettings.headTilt) * CF(0, 0.5, 0), Sine, S.aimSettings.Speed)
		local t0 = tick()
		while true do
			RS.RenderStepped:wait()
			local Alpha = math.min((tick() - t0) / S.aimSettings.Speed, 1) * 90
			if (not Aimed) then break end
			if (not Selected) then break end
			aimAlpha = Sine(Alpha)
			aimHeadOffset = headOffset.X * aimAlpha
			jumpAnimMultiplier = numLerp(1, S.fallSettings.aimEffect, aimAlpha)
			translationDivisor = numLerp(7, 20, aimAlpha)
			rotationMultiplier = numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha)
			armTiltMultiplier = numLerp(1, 0.2, aimAlpha)
			Cam.FieldOfView = numLerp(currentFOV, S.aimSettings.FOV, aimAlpha)
			if S.guiScope then
				Scope.BackgroundTransparency = numLerp(currentTrans, 0, aimAlpha)
			end
			if Alpha == 90 then break end
		end
	else
		LWeld.C0, LWeld.C1 = armC0[1], S.aimedC1.leftArm
		RWeld.C0, RWeld.C1 = armC0[2], S.aimedC1.rightArm
		LWeld2.C1, RWeld2.C1 = CF(), CF()
		animWeld.C0 = CF(0, 1, 0)
		Grip.C1 = aimedGripCF
		headWeld2.C1 = CF(0, -0.5, 0) * CFANG(0, 0, S.aimSettings.headTilt) * CF(0, 0.5, 0)
		aimAlpha = 1
		aimHeadOffset = headOffset.X
		jumpAnimMultiplier = S.fallSettings.aimEffect
		translationDivisor = 20
		rotationMultiplier = S.momentumSettings.Amplitude.Aimed
		armTiltMultiplier = 0.2
		Cam.FieldOfView = S.aimSettings.FOV
	end
	Aiming = (not Aimed)
	if (not Aiming) and S.guiScope then
		spawn(function()
			scopeSteady.Visible = true
			Scope.BackgroundTransparency = 1
			scopeMain.Visible = true
			
			if armTable then
				for _, Obj in pairs(armTable[1].Model:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 1
					end
				end
				for _, Obj in pairs(armTable[2].Model:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 1
					end
				end
			elseif armModel then
				for _, Obj in pairs(armModel:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 1
					end
				end
			end
			for _, Obj in pairs(playerFolder:GetChildren()) do
				if Obj:IsA("BasePart") then
					Obj.LocalTransparencyModifier = 1
				end
			end
			for _, Obj in pairs(Gun:GetChildren()) do
				if Obj:IsA("BasePart") then
					Obj.LocalTransparencyModifier = 1
				end
			end
		end)
		spawn(function()
			local camAng = 0
			local idleCam = function()
				return V3(
					RAD(SIN(camAng * S.scopeSettings.Frequency.Idling)) * stanceSway * camSway * S.scopeSettings.Amplitude.Idling,
					RAD(SIN(camAng * 5 / 2 * S.scopeSettings.Frequency.Idling)) * stanceSway * camSway * S.scopeSettings.Amplitude.Idling * 0.75,
					0
				)
			end
			local walkCam = function()
				return V3(
					RAD(SIN(camAng * S.scopeSettings.Frequency.Walking)) * camSway * stanceSway * S.scopeSettings.Amplitude.Walking,
					RAD(SIN(camAng * 5 / 2 * S.scopeSettings.Frequency.Walking)) * camSway * stanceSway * S.scopeSettings.Amplitude.Walking * 0.75,
					0
				)
			end
			while Aimed do
				local dt = RS.RenderStepped:wait()
				camOffsets.guiScope.Rot = (Sine(idleAlpha) * idleCam()) + (Sine(walkAlpha) * walkCam())
				camAng = camAng + RAD(105 * dt) * stanceSway * camSway
			end
		end)
	end
end

function unAimGun(Exception)
	if (not S.canADS) then return end
	
	mouseSensitivity = S.sensitivitySettings.Default
	
	for _, Plugin in pairs(Plugins.UnAimed) do
		spawn(function()
			Plugin()
		end)
	end
	
	if S.guiScope then
		spawn(function()
			if armTable then
				for _, Obj in pairs(armTable[1].Model:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 0
					end
				end
				for _, Obj in pairs(armTable[2].Model:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 0
					end
				end
			elseif armModel then
				for _, Obj in pairs(armModel:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 0
					end
				end
			end
			for _, Obj in pairs(playerFolder:GetChildren()) do
				if Obj:IsA("BasePart") then
					Obj.LocalTransparencyModifier = 0
				end
			end
			for _, Obj in pairs(Gun:GetChildren()) do
				if Obj:IsA("BasePart") then
					Obj.LocalTransparencyModifier = 0
				end
			end
		end)
	end
	
	if (not Exception) then
		if (not Aimed) then return end
		if (Reloading and Exception) or Knifing then return end
		spreadZoom = "unAimed"
		baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
		Aimed = false
		Aiming = true
		if S.aimSettings.Anim then
			local currentFOV = Cam.FieldOfView
			local currentTrans = (Scope.BackgroundTransparency == 1 and (S.guiScope and 0 or 1) or Scope.BackgroundTransparency)
			scopeMain.Visible = false
			scopeSteady.Visible = false
			tweenJoint(LWeld, armC0[1], S.unAimedC1.leftArm, Sine, S.aimSettings.Speed)
			tweenJoint(RWeld, armC0[2], S.unAimedC1.rightArm, Sine, S.aimSettings.Speed)
			tweenJoint(headWeld2, nil, CF(), Sine, S.aimSettings.Speed)
			tweenJoint(Grip, nil, S.unAimedC1.Grip, Sine, S.aimSettings.Speed)
			local t0 = tick()
			while true do
				RS.RenderStepped:wait()
				local Alpha = math.min((tick() - t0) / S.aimSettings.Speed, 1) * 90
				if Aimed then break end
				if (not Selected) then break end
				aimAlpha = 1 - Sine(Alpha)--1 - COS(RAD(X))
				aimHeadOffset = headOffset.X * aimAlpha
				jumpAnimMultiplier = numLerp(1, S.fallSettings.aimEffect, aimAlpha)
				translationDivisor = numLerp(7, 20, aimAlpha)
				rotationMultiplier = numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha)
				armTiltMultiplier = numLerp(1, 0.2, aimAlpha)
				Cam.FieldOfView = numLerp(80, currentFOV, aimAlpha)
				Scope.BackgroundTransparency = numLerp(1, currentTrans, aimAlpha)
				if Alpha == 90 then break end
			end
		else
			scopeMain.Visible = false
			scopeSteady.Visible = false
			LWeld.C0, LWeld.C1 = armC0[1], S.unAimedC1.leftArm
			RWeld.C0, RWeld.C1 = armC0[2], S.unAimedC1.rightArm
			headWeld2.C0 = CF()
			Grip.C1 = S.unAimedC1.Grip
			aimAlpha = 0
			aimHeadOffset = 0
			jumpAnimMultiplier = 1
			translationDivisor = 7
			rotationMultiplier = S.momentumSettings.Amplitude.unAimed
			armTiltMultiplier = 1
			Cam.FieldOfView = 80
			Scope.BackgroundTransparency = 1
		end
		Aiming = Aimed
	else
		spawn(function()
			Aimed = false
			Aiming = false
			spreadZoom = "unAimed"
			baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
			local currentFOV = Cam.FieldOfView
			local currentTrans = (Scope.BackgroundTransparency == 1 and (S.guiScope and 0 or 1) or Scope.BackgroundTransparency)
			scopeMain.Visible = false
			scopeSteady.Visible = false
			tweenJoint(headWeld2, nil, CF(), Sine, S.aimSettings.Speed)
			if S.aimSettings.Anim then
				local t0 = tick()
				while true do
					RS.RenderStepped:wait()
					local Alpha = math.min((tick() - t0) / S.aimSettings.Speed, 1) * 90
					if Aimed then break end
					if (not Selected) then break end
					aimAlpha = 1 - Sine(Alpha)--1 - COS(RAD(90 - Alpha))
					aimHeadOffset = headOffset.X * aimAlpha
					jumpAnimMultiplier = numLerp(1, S.fallSettings.aimEffect, aimAlpha)
					translationDivisor = numLerp(7, 20, aimAlpha)
					rotationMultiplier = numLerp(S.momentumSettings.Amplitude.unAimed, S.momentumSettings.Amplitude.Aimed, aimAlpha)
					armTiltMultiplier = numLerp(1, 0.2, aimAlpha)
					Cam.FieldOfView = numLerp(80, currentFOV, aimAlpha)
					Scope.BackgroundTransparency = numLerp(1, currentTrans, aimAlpha)
					if Alpha == 90 then break end
				end
			else
				scopeMain.Visible = false
				scopeSteady.Visible = false
				aimAlpha = 0
				aimHeadOffset = 0
				jumpAnimMultiplier = 1
				translationDivisor = 7
				rotationMultiplier = S.momentumSettings.Amplitude.unAimed
				armTiltMultiplier = 1
				Cam.FieldOfView = 80
				Scope.BackgroundTransparency = 1
			end
		end)
	end
end
