Run.RenderStepped:Connect(function(a)HeadMovement()renderGunRecoil()renderCam()if ViewModel and(LArm and(RArm and WeaponInHand))then local w=User:GetMouseDelta()SwaySpring:accelerate(Vector3.new(w.x/60,w.y/60,0))local j=SwaySpring.p local O=j.z local T=j.X local H=j.Y local n=CFrame.Angles(H,T,T)if BipodAtt then local a=Ray.new(UnderBarrelAtt.Main.Position,Vector3.new(0,-1.75,0))local w,j,O=workspace:FindPartOnRayWithIgnoreList(a,Ignore_Model,false,true)if w then CanBipod=true if CanBipod and(BipodActive and(not runKeyDown and(GunStance==0 or GunStance==2)))then(TS:Create(SE_GUI.GunHUD.Att.Bipod,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,255,255),ImageTransparency=.123})):Play()if not aimming then BipodCF=BipodCF:Lerp(CFrame.new(0,((UnderBarrelAtt.Main.Position-j).magnitude-1)*-1.5,0),.2)else BipodCF=BipodCF:Lerp(CFrame.new(),.2)end else BipodActive=false BipodCF=BipodCF:Lerp(CFrame.new(),.2);(TS:Create(SE_GUI.GunHUD.Att.Bipod,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,255,0);ImageTransparency=.5})):Play()end else BipodActive=false CanBipod=false BipodCF=BipodCF:Lerp(CFrame.new(),.2);(TS:Create(SE_GUI.GunHUD.Att.Bipod,TweenInfo.new(.1,Enum.EasingStyle.Linear),{ImageColor3=Color3.fromRGB(255,0,0);ImageTransparency=.5})):Play()end end AnimPart.CFrame=((((cam.CFrame*NearZ)*BipodCF)*maincf)*gunbobcf)*aimcf if not AnimData.GunModelFixed then WeaponInHand:SetPrimaryPartCFrame(ViewModel.PrimaryPart.CFrame*guncf)end if running then gunbobcf=gunbobcf:Lerp(CFrame.new((.025*(charspeed/10))*math.sin(tick()*8),(.025*(charspeed/10))*math.cos(tick()*16),0)*CFrame.Angles(math.rad((1*(charspeed/10))*math.sin(tick()*16)),math.rad((1*(charspeed/10))*math.cos(tick()*8)),math.rad(0)),.1)else gunbobcf=gunbobcf:Lerp(CFrame.new(.005*math.sin(tick()*1.5),.005*math.cos(tick()*2.5),0),1)end local C=0 if WeaponData.adsTime then C+=a/(WeaponData.adsTime*.1)else C=.2 end if CurAimpart and(aimming and(AnimDebounce and not CheckingMag))then if not NVG or WeaponInHand.AimPart:FindFirstChild("\078\086\065\105\109")==nil then if AimPartMode==1 then(TS:Create(cam,AimTween,{FieldOfView=ModTable.ZoomValue})):Play()maincf=maincf:Lerp((((maincf*CFrame.new(0,0,-0.5))*recoilcf)*n:inverse())*CurAimpart.CFrame:toObjectSpace(cam.CFrame),C)else(TS:Create(cam,AimTween,{FieldOfView=ModTable.Zoom2Value})):Play()maincf=maincf:Lerp((((maincf*CFrame.new(0,0,-0.5))*recoilcf)*n:inverse())*CurAimpart.CFrame:toObjectSpace(cam.CFrame),C)end else(TS:Create(cam,AimTween,{FieldOfView=70})):Play()maincf=maincf:Lerp((((maincf*CFrame.new(0,0,-0.5))*recoilcf)*n:inverse())*(WeaponInHand.AimPart.CFrame*WeaponInHand.AimPart.NVAim.CFrame):toObjectSpace(cam.CFrame),C)end else(TS:Create(cam,AimTween,{FieldOfView=70})):Play()maincf=maincf:Lerp((AnimData.MainCFrame*recoilcf)*n:inverse(),C)end for a,w in pairs(WeaponInHand:GetDescendants())do if w:IsA("\066\097\115\101\080\097\114\116")and w.Name=="\083\105\103\104\116\077\097\114\107"then local a=w.CFrame:pointToObjectSpace(cam.CFrame.Position)/w.Size local j=w.SurfaceGui.Border.Scope j.Position=UDim2.new(.5+a.x,0,.5-a.y,0)if w.SurfaceGui.Border:FindFirstChild("\086\105\103\110\101\116\116\101")then end end end recoilcf=recoilcf:Lerp(CFrame.new()*CFrame.Angles(math.rad(RecoilSpring.p.X),math.rad(RecoilSpring.p.Y),math.rad(RecoilSpring.p.z)),C)if WeaponData.CrossHair then if aimming then CHup=CHup:Lerp(UDim2.new(.5,0,.5,0),C)CHdown=CHdown:Lerp(UDim2.new(.5,0,.5,0),C)CHleft=CHleft:Lerp(UDim2.new(.5,0,.5,0),C)CHright=CHright:Lerp(UDim2.new(.5,0,.5,0),C)else local a=(((WeaponData.CrosshairOffset+BSpread)+(charspeed*WeaponData.WalkMult)*ModTable.WalkMult)/50)/10 CHup=CHup:Lerp(UDim2.new(.5,0,.5-a,0),.5)CHdown=CHdown:Lerp(UDim2.new(.5,0,.5+a,0),.5)CHleft=CHleft:Lerp(UDim2.new(.5-a,0,.5,0),.5)CHright=CHright:Lerp(UDim2.new(.5+a,0,.5,0),.5)end Crosshair.Position=UDim2.new(0,mouse.X,0,mouse.Y)Crosshair.Up.Position=CHup Crosshair.Down.Position=CHdown Crosshair.Left.Position=CHleft Crosshair.Right.Position=CHright else CHup=CHup:Lerp(UDim2.new(.5,0,.5,0),C)CHdown=CHdown:Lerp(UDim2.new(.5,0,.5,0),C)CHleft=CHleft:Lerp(UDim2.new(.5,0,.5,0),C)CHright=CHright:Lerp(UDim2.new(.5,0,.5,0),C)Crosshair.Position=UDim2.new(0,mouse.X,0,mouse.Y)Crosshair.Up.Position=CHup Crosshair.Down.Position=CHdown Crosshair.Left.Position=CHleft Crosshair.Right.Position=CHright end if BSpread then local a=time()if a-LastSpreadUpdate>(60/WeaponData.ShootRate)*2 and(not shooting and BSpread>WeaponData.MinSpread*ModTable.MinSpread)then BSpread=math.max(WeaponData.MinSpread*ModTable.MinSpread,BSpread-WeaponData.AimInaccuracyDecrease*ModTable.AimInaccuracyDecrease)end if a-LastSpreadUpdate>(60/WeaponData.ShootRate)*1.5 and(not shooting and RecoilPower>WeaponData.MinRecoilPower*ModTable.MinRecoilPower)then RecoilPower=math.max(WeaponData.MinRecoilPower*ModTable.MinRecoilPower,RecoilPower-WeaponData.RecoilPowerStepAmount*ModTable.RecoilPowerStepAmount)end end if LaserActive and Pointer~=nil then if NVG then Pointer.Transparency=0 Pointer.Beam.Enabled=true else if not gameRules.RealisticLaser then Pointer.Beam.Enabled=true else Pointer.Beam.Enabled=false end if IRmode then Pointer.Transparency=1 else Pointer.Transparency=0 end end for a,w in pairs(WeaponInHand:GetDescendants())do if w:IsA("\066\097\115\101\080\097\114\116")and w.Name=="\076\097\115\101\114\080\111\105\110\116"then local a=Ray.new(w.CFrame.Position,w.CFrame.LookVector*1000)local j,O,T=workspace:FindPartOnRayWithIgnoreList(a,Ignore_Model,false,true)if j then Pointer.CFrame=CFrame.new(O,O+T)else Pointer.CFrame=CFrame.new(cam.CFrame.Position+w.CFrame.LookVector*2000,w.CFrame.LookVector)end if HalfStep and gameRules.ReplicatedLaser then Evt.SVLaser:FireServer(O,1,Pointer.Color,IRmode,WeaponTool)end break end end end end if ACS_Client:GetAttribute("\083\117\114\114\101\110\100\101\114")then char.Humanoid.WalkSpeed=0 elseif script.Parent:GetAttribute("\073\110\106\117\114\101\100")then SetWalkSpeed(gameRules.InjuredCrouchWalkSpeed)elseif runKeyDown then SetWalkSpeed(gameRules.RunWalkSpeed)Crouched=false Proned=false elseif Crouched then SetWalkSpeed(gameRules.CrouchWalkSpeed)elseif Proned then SetWalkSpeed(gameRules.ProneWalksSpeed)elseif Steady then SetWalkSpeed(gameRules.SlowPaceWalkSpeed)else SetWalkSpeed(gameRules.NormalWalkSpeed)end end)
----------//Render Functions\\----------
Run.RenderStepped:Connect(function(step)
	HeadMovement()
	renderGunRecoil()
	renderCam()

	if ViewModel and LArm and RArm and WeaponInHand then --Check if the weapon and arms are loaded
		local mouseDelta = User:GetMouseDelta()
		SwaySpring:accelerate(Vector3.new(mouseDelta.x / 60, mouseDelta.y / 60, 0))

		local swayVec = SwaySpring.p
		local TSWAY = swayVec.z
		local XSSWY = swayVec.X
		local YSSWY = swayVec.Y
		local Sway = CFrame.Angles(YSSWY, XSSWY, XSSWY)

		if BipodAtt then
			local BipodRay = Ray.new(UnderBarrelAtt.Main.Position, Vector3.new(0, -1.75, 0))
			local BipodHit, BipodPos, BipodNorm =
				workspace:FindPartOnRayWithIgnoreList(BipodRay, Ignore_Model, false, true)

			if BipodHit then
				CanBipod = true
				if CanBipod and BipodActive and not runKeyDown and (GunStance == 0 or GunStance == 2) then
					TS:Create(
						SE_GUI.GunHUD.Att.Bipod,
						TweenInfo.new(0.1, Enum.EasingStyle.Linear),
						{ ImageColor3 = Color3.fromRGB(255, 255, 255), ImageTransparency = 0.123 }
					):Play()
					if not aimming then
						BipodCF = BipodCF:Lerp(
							CFrame.new(0, ((UnderBarrelAtt.Main.Position - BipodPos).magnitude - 1) * -1.5, 0),
							0.2
						)
					else
						BipodCF = BipodCF:Lerp(CFrame.new(), 0.2)
					end
				else
					BipodActive = false
					BipodCF = BipodCF:Lerp(CFrame.new(), 0.2)
					TS:Create(
						SE_GUI.GunHUD.Att.Bipod,
						TweenInfo.new(0.1, Enum.EasingStyle.Linear),
						{ ImageColor3 = Color3.fromRGB(255, 255, 0), ImageTransparency = 0.5 }
					):Play()
				end
			else
				BipodActive = false
				CanBipod = false
				BipodCF = BipodCF:Lerp(CFrame.new(), 0.2)
				TS:Create(
					SE_GUI.GunHUD.Att.Bipod,
					TweenInfo.new(0.1, Enum.EasingStyle.Linear),
					{ ImageColor3 = Color3.fromRGB(255, 0, 0), ImageTransparency = 0.5 }
				):Play()
			end
		end

		AnimPart.CFrame = cam.CFrame * NearZ * BipodCF * maincf * gunbobcf * aimcf

		if not AnimData.GunModelFixed then
			WeaponInHand:SetPrimaryPartCFrame(ViewModel.PrimaryPart.CFrame * guncf)
		end

		if running then
			gunbobcf = gunbobcf:Lerp(
				CFrame.new(
					0.025 * (charspeed / 10) * math.sin(tick() * 8),
					0.025 * (charspeed / 10) * math.cos(tick() * 16),
					0
				)
					* CFrame.Angles(
						math.rad(1 * (charspeed / 10) * math.sin(tick() * 16)),
						math.rad(1 * (charspeed / 10) * math.cos(tick() * 8)),
						math.rad(0)
					),
				0.1
			)
		else
			gunbobcf = gunbobcf:Lerp(CFrame.new(0.005 * math.sin(tick() * 1.5), 0.005 * math.cos(tick() * 2.5), 0), 1)
		end

		local AimTiming = 0
		if WeaponData.adsTime then
			AimTiming += step / (WeaponData.adsTime * 0.1)
		else
			AimTiming = 0.2
		end
		if CurAimpart and aimming and AnimDebounce and not CheckingMag then
			if not NVG or WeaponInHand.AimPart:FindFirstChild("NVAim") == nil then
				if AimPartMode == 1 then
					TS:Create(cam, AimTween, { FieldOfView = ModTable.ZoomValue }):Play()
					maincf = maincf:Lerp(
						maincf
							* CFrame.new(0, 0, -0.5)
							* recoilcf
							* Sway:inverse()
							* CurAimpart.CFrame:toObjectSpace(cam.CFrame),
						AimTiming
					)
				else
					TS:Create(cam, AimTween, { FieldOfView = ModTable.Zoom2Value }):Play()
					maincf = maincf:Lerp(
						maincf
							* CFrame.new(0, 0, -0.5)
							* recoilcf
							* Sway:inverse()
							* CurAimpart.CFrame:toObjectSpace(cam.CFrame),
						AimTiming
					)
				end
			else
				TS:Create(cam, AimTween, { FieldOfView = 70 }):Play()
				maincf = maincf:Lerp(
					maincf
						* CFrame.new(0, 0, -0.5)
						* recoilcf
						* Sway:inverse()
						* (WeaponInHand.AimPart.CFrame * WeaponInHand.AimPart.NVAim.CFrame):toObjectSpace(cam.CFrame),
					AimTiming
				)
			end
		else
			TS:Create(cam, AimTween, { FieldOfView = 70 }):Play()
			maincf = maincf:Lerp(AnimData.MainCFrame * recoilcf * Sway:inverse(), AimTiming)
		end

		for index, Part in pairs(WeaponInHand:GetDescendants()) do
			if Part:IsA("BasePart") and Part.Name == "SightMark" then
				local dist_scale = Part.CFrame:pointToObjectSpace(cam.CFrame.Position) / Part.Size
				local reticle = Part.SurfaceGui.Border.Scope
				reticle.Position = UDim2.new(0.5 + dist_scale.x, 0, 0.5 - dist_scale.y, 0)
				if Part.SurfaceGui.Border:FindFirstChild("Vignette") then
					--Part.SurfaceGui.Border.Vignette.Position = reticle.Position
				end
			end
		end

		recoilcf = recoilcf:Lerp(
			CFrame.new()
				* CFrame.Angles(math.rad(RecoilSpring.p.X), math.rad(RecoilSpring.p.Y), math.rad(RecoilSpring.p.z)),
			AimTiming
		)

		if WeaponData.CrossHair then
			if aimming then
				CHup = CHup:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
				CHdown = CHdown:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
				CHleft = CHleft:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
				CHright = CHright:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
			else
				local Normalized = (
					(WeaponData.CrosshairOffset + BSpread + (charspeed * WeaponData.WalkMult * ModTable.WalkMult)) / 50
				) / 10

				CHup = CHup:Lerp(UDim2.new(0.5, 0, 0.5 - Normalized, 0), 0.5)
				CHdown = CHdown:Lerp(UDim2.new(0.5, 0, 0.5 + Normalized, 0), 0.5)
				CHleft = CHleft:Lerp(UDim2.new(0.5 - Normalized, 0, 0.5, 0), 0.5)
				CHright = CHright:Lerp(UDim2.new(0.5 + Normalized, 0, 0.5, 0), 0.5)
			end

			Crosshair.Position = UDim2.new(0, mouse.X, 0, mouse.Y)

			Crosshair.Up.Position = CHup
			Crosshair.Down.Position = CHdown
			Crosshair.Left.Position = CHleft
			Crosshair.Right.Position = CHright
		else
			CHup = CHup:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
			CHdown = CHdown:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
			CHleft = CHleft:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)
			CHright = CHright:Lerp(UDim2.new(0.5, 0, 0.5, 0), AimTiming)

			Crosshair.Position = UDim2.new(0, mouse.X, 0, mouse.Y)

			Crosshair.Up.Position = CHup
			Crosshair.Down.Position = CHdown
			Crosshair.Left.Position = CHleft
			Crosshair.Right.Position = CHright
		end

		if BSpread then
			local currTime = time()
			if
				currTime - LastSpreadUpdate > (60 / WeaponData.ShootRate) * 2
				and not shooting
				and BSpread > WeaponData.MinSpread * ModTable.MinSpread
			then
				BSpread = math.max(
					WeaponData.MinSpread * ModTable.MinSpread,
					BSpread - WeaponData.AimInaccuracyDecrease * ModTable.AimInaccuracyDecrease
				)
			end
			if
				currTime - LastSpreadUpdate > (60 / WeaponData.ShootRate) * 1.5
				and not shooting
				and RecoilPower > WeaponData.MinRecoilPower * ModTable.MinRecoilPower
			then
				RecoilPower = math.max(
					WeaponData.MinRecoilPower * ModTable.MinRecoilPower,
					RecoilPower - WeaponData.RecoilPowerStepAmount * ModTable.RecoilPowerStepAmount
				)
			end
		end

		if LaserActive and Pointer ~= nil then
			if NVG then
				Pointer.Transparency = 0
				Pointer.Beam.Enabled = true
			else
				if not gameRules.RealisticLaser then
					Pointer.Beam.Enabled = true
				else
					Pointer.Beam.Enabled = false
				end
				if IRmode then
					Pointer.Transparency = 1
				else
					Pointer.Transparency = 0
				end
			end

			for index, Key in pairs(WeaponInHand:GetDescendants()) do
				if Key:IsA("BasePart") and Key.Name == "LaserPoint" then
					local L_361_ = Ray.new(Key.CFrame.Position, Key.CFrame.LookVector * 1000)
					local Hit, Pos, Normal = workspace:FindPartOnRayWithIgnoreList(L_361_, Ignore_Model, false, true)

					if Hit then
						Pointer.CFrame = CFrame.new(Pos, Pos + Normal)
					else
						Pointer.CFrame =
							CFrame.new(cam.CFrame.Position + Key.CFrame.LookVector * 2000, Key.CFrame.LookVector)
					end

					if HalfStep and gameRules.ReplicatedLaser then
						Evt.SVLaser:FireServer(Pos, 1, Pointer.Color, IRmode, WeaponTool)
					end
					break
				end
			end
		end
	end

	if ACS_Client:GetAttribute("Surrender") then
		char.Humanoid.WalkSpeed = 0
	elseif script.Parent:GetAttribute("Injured") then
		SetWalkSpeed(gameRules.InjuredCrouchWalkSpeed)
	elseif runKeyDown then
		SetWalkSpeed(gameRules.RunWalkSpeed)
		Crouched = false
		Proned = false
	elseif Crouched then
		SetWalkSpeed(gameRules.CrouchWalkSpeed)
	elseif Proned then
		SetWalkSpeed(gameRules.ProneWalksSpeed)
	elseif Steady then
		SetWalkSpeed(gameRules.SlowPaceWalkSpeed)
	else
		SetWalkSpeed(gameRules.NormalWalkSpeed)
	end
end)
