-- ModuleScript Rifle (via bytefall decompiler) -- Decompiled using ByteFall -- discord.gg/pHTnqmmWzk local module: {[any]: any} = {} module.__index = module module.ClassName = "Rifle" local replicatedStorage: ReplicatedStorage = game:GetService("ReplicatedStorage") local tweenService: TweenService = game:GetService("TweenService") local runService: RunService = game:GetService("RunService") local players: Players = game:GetService("Players") local userInputService: UserInputService = game:GetService("UserInputService") game:GetService("HapticService") local collectionService: CollectionService = game:GetService("CollectionService") local guiService: GuiService = game:GetService("GuiService") local sound = require(replicatedStorage.ReservesCommon.Domain.Sound) local maid = require(replicatedStorage.Classes.Maid) local spring = require(replicatedStorage.Classes.Spring) local lerpValue = require(replicatedStorage.Classes.LerpValue) local signal = require(replicatedStorage.Classes.Signal) local dynamicThumbstick = require(replicatedStorage.Classes.DynamicThumbstick) local fusion = require(replicatedStorage.Packages.Fusion) local router = require(replicatedStorage.Common.UI.Router) local v17 = if runService:IsClient() then require(replicatedStorage.Common.UI.Modal) else nil local util = require(replicatedStorage.ReservesCommon.Util) local cameraController = require(replicatedStorage.ReservesCommon.Client.Controllers.CameraController) local ammunition = require(replicatedStorage.ReservesCommon.Ammunition) local projectileController = nil local CurrentCamera: Camera = workspace.CurrentCamera local function HandleAction(p1, p2, p3, _) if p2 == "Aim" then if not p1._replica.Data.Settings.ToggleAim then if p3 == Enum.UserInputState.Begin then p1.Input.HoldingAim = true p1:SetAimIntent(true) elseif p3 == Enum.UserInputState.End or p3 == Enum.UserInputState.Cancel then p1.Input.HoldingAim = false p1:SetAimIntent(false) end elseif p3 == Enum.UserInputState.Begin then p1:SetAimIntent(not p1.WantsAim) end end if p2 == "Fire" and p3 == Enum.UserInputState.Begin then p1:Fire() end if p2 == "Reload" and p3 == Enum.UserInputState.Begin then p1:Reload() end end local function isGameplay() return fusion.peek(router.State).Name == "Gameplay" end local function updateDynamicThumbstick(p5, p6) if not userInputService.TouchEnabled or not p5.ScopeGui then return end if p6 and not p5._dynamicThumbstick then p5._dynamicThumbstick = dynamicThumbstick.new("Gameplay") p5._maid:GiveTask(p5._dynamicThumbstick) end if not p5._dynamicThumbstick then return end if p6 and p5.Aiming then p5._dynamicThumbstick:Enable(true, p5.ScopeGui) return end p5._dynamicThumbstick:Enable(false) end local function hideViewmodel(p7) if p7._hiddenViewmodelParts then return end p7._hiddenViewmodelParts = {} p7._hiddenViewmodelImages = {} for _, v in ipairs(p7._viewmodel._viewmodel:GetDescendants()) do if v:IsA("BasePart") then p7._hiddenViewmodelParts[v] = v.LocalTransparencyModifier v.LocalTransparencyModifier = 1 elseif v:IsA("Decal") or v:IsA("Texture") then p7._hiddenViewmodelImages[v] = v.Transparency v.Transparency = 1 end end end local function showViewmodel(p8) for k, v in pairs(p8._hiddenViewmodelParts or {}) do if k.Parent then k.LocalTransparencyModifier = v end end for k, v in pairs(p8._hiddenViewmodelImages or {}) do if k.Parent then k.Transparency = v end end p8._hiddenViewmodelParts = nil p8._hiddenViewmodelImages = nil end function module.new(p9, p10, ammunition, p12, p13) local object = setmetatable({}, module) object.Aiming = false object.WantsAim = false object._lifetime = { Alive = true, AimRevision = 0 } router.Context.IsScoped:set(false) object.Reloading = false object.AimTransition = false object.NeedsLoading = false object.NeedsReloading = false object._maid = maid.new() object._modelReference = p10 object.Attachments = { Sight = nil, Muzzle = nil } object.Input = { HoldingAim = false } object.Ammunition = ammunition local configuration = require(p10.Configuration) object.DisplayName = configuration.DisplayName object.Configurations = { Muzzle = nil, Class = configuration.Class, ReloadSequence = configuration.ReloadSequence, Sight = { HasGui = false, IsThermal = false, Magnification = configuration.DefaultAimMagnification, Sensitivity = configuration.DefaultAimSensitivity } } object.MagazineCapacity = configuration.MagazineCapacity object.MuzzleVelocity = configuration.Ammunition[ammunition].MuzzleVelocity object.LoadBetweenRounds = configuration.LoadBetweenRounds object.AutomaticReloadAfterShot = configuration.AutomaticReloadAfterShot object.FireRate = configuration.FireRate object.WalkSpeedPenalty = configuration.WalkSpeedPenalty object.RunSpeedPenalty = configuration.RunSpeedPenalty object.AimLerp = lerpValue.new() object._aimCancel = signal.new() object.Model = object:GetModel(p9) object.BulletsInMagazine = math.clamp(p13 or 0, 0, object.MagazineCapacity) object.ClassName = module.ClassName local v56 = spring.new() local v57 = spring.new(nil, nil, 3, 3) object.Springs = { Parallax = v56, ScopeOffset = v57 } object._maid:GiveTask(object.Model) object.VerticalRecoil = configuration.VerticalRecoil if object.Configurations.Muzzle then object.VerticalRecoil = configuration.VerticalRecoil - configuration.VerticalRecoil * (object.Configurations.Muzzle.RecoilReduction / 100) end object.NoiseRange = configuration.NoiseRange if object.Configurations.Muzzle and object.Configurations.Muzzle.Type == "Suppressor" then object.NoiseRange = object.NoiseRange - object.Configurations.Muzzle.NoiseDampening end if p12 then object._measurementModule = require(replicatedStorage.ReservesCommon.MeasurementModule) if not projectileController then projectileController = require(replicatedStorage.ReservesCommon.Client.Controllers.ProjectileController) end local PlayerGui = players.LocalPlayer.PlayerGui object._viewmodel = p12 object._replica = require(replicatedStorage.Common.Client.Controllers.ReplicaController):WaitForReplica("PlayerData") local inputHandler = require(replicatedStorage.Common.InputHandler) object._inputContext = inputHandler.PushContext("Weapon") object._inputContext:SetBlocking(false) object._maid:GiveTask(function() object._inputContext:Destroy() end) object._inputContext:Bind("Aim", { Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2 }, function(p14, p15) HandleAction(object, "Aim", p14, p15) end) object._inputContext:Bind("Fire", { Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonR2, Enum.KeyCode.Space }, function(p16, _) if p16 == Enum.UserInputState.Begin then object:Fire() end end) object._inputContext:Bind("Reload", { Enum.KeyCode.R, Enum.KeyCode.ButtonX }, function(p18, _) if p18 == Enum.UserInputState.Begin then object:Reload() end end) inputHandler.TouchButtons.Fire.Visible:set(false) inputHandler.TouchButtons.Aim.Active:set(false) inputHandler.TouchButtons.Aim.Visible:set(true) inputHandler.TouchButtons.Reload.Visible:set(true) object._inputContext:BindTouchButton("Aim", function(p20) if p20 == Enum.UserInputState.Begin then object:SetAimIntent(not object.WantsAim) end end) object._inputContext:BindTouchButton("Fire", function(p21) if p21 == Enum.UserInputState.Begin then object:Fire() end end) object._inputContext:BindTouchButton("Reload", function(p22) if p22 == Enum.UserInputState.Begin then object:Reload() end end) object._maid:GiveTask(function() inputHandler.TouchButtons.Fire.Visible:set(false) inputHandler.TouchButtons.Aim.Visible:set(false) inputHandler.TouchButtons.Reload.Visible:set(false) end) local function cancelUnavailableAim() if not object:CanAim() then object:ClearAimIntent() end end local object_maid = object._maid local v62 = router.Scope:Observer(router.State) object_maid:GiveTask(v62:onChange(cancelUnavailableAim)) local v63 = object._maid v62 = router.Scope:Observer(v17.State) v63:GiveTask(v62:onChange(cancelUnavailableAim)) local v64 = object._maid v62 = router.Scope:Observer(router.Context.IsTeleporting) v64:GiveTask(v62:onChange(cancelUnavailableAim)) object._maid:GiveTask(inputHandler.StackChanged:Connect(cancelUnavailableAim)) object._maid:GiveTask(guiService.MenuOpened:Connect(function() object:ClearAimIntent() end)) object._maid:GiveTask(userInputService.WindowFocusReleased:Connect(function() object:ClearAimIntent() end)) if object.Attachments.Sight and object.Configurations.Sight.HasGui then object.ScopeGui = object.Attachments.Sight.ScopeGui:Clone() object._maid:GiveTask(router.BindToScreen("Gameplay", object.ScopeGui)) updateDynamicThumbstick(object, object._replica.Data.Settings.ThumbstickAim) object._maid:GiveTask(object._replica:OnSet({ "Settings", "ThumbstickAim" }, function(p23) updateDynamicThumbstick(object, p23) end)) object._maid:GiveTask(object.ScopeGui) end v62 = object._viewmodel._character.Humanoid.Animator:LoadAnimation(object.Model.CharacterAnimations.Idle) local animationTrack = object._viewmodel._character.Humanoid.Animator:LoadAnimation(object.Model.CharacterAnimations.ProneAim) local v66 = object._viewmodel._character.Humanoid.Animator:LoadAnimation(object.Model.CharacterAnimations.CrouchAim) local v67 = object._viewmodel._character.Humanoid.Animator:LoadAnimation(object.Model.CharacterAnimations.StandingAim) object.LoadedAnimations = { Viewmodel = {}, Character = { Idle = v62, ProneAim = animationTrack, CrouchAim = v66, StandingAim = v67 } } for _, v in ipairs(object.Model.ViewmodelAnimations:GetChildren()) do object.LoadedAnimations.Viewmodel[v.Name] = object._viewmodel:LoadAnimation(v) end object.LoadedSounds = {} for _, v in ipairs(object.Model.ViewmodelAnimations:GetChildren()) do for _, iterValue in ipairs(v:GetChildren()) do if iterValue:IsA("Sound") and not object.LoadedSounds[iterValue.Name] then object.LoadedSounds[iterValue.Name] = sound.new(iterValue.SoundId, object.Model.PrimaryPart, { ApplyDistanceEffects = false, DestroyOnEnded = false, ConnectToAnalyzer = true }) object._maid:GiveTask(object.LoadedSounds[iterValue.Name]) end end end for _, v in pairs(object.LoadedAnimations.Viewmodel) do local v76 = object._maid local v77 = v:GetMarkerReachedSignal("Sound") v76:GiveTask(v77:Connect(function(p24) if not object.LoadedSounds[p24] then local v199 = ("%* is not loaded"):format(p24) warn(v199) return end object.LoadedSounds[p24]:Play() end)) end object.GunGui = object.Model.GunGui:Clone() object.GunGui.WeaponStats.WeaponNameLabel.Text = configuration.DisplayName object.GunGui.AncestryChanged:Connect(function() if object and object._updateGui then object:_updateGui() end end) object._maid:GiveTask(router.BindToScreen("Gameplay", object.GunGui)) object.Loaded = true object._maid:GiveTask(object._replica:OnChange(function(_, p26) if p26[1] == "Ammunition" and object and object._updateGui then object:_updateGui() end end)) object._maid:GiveTask(object.GunGui) object:_updateGui() if configuration.AnimationExtraParts then local n1: number = 0 for k, v in pairs(configuration.AnimationExtraParts) do for i = 1, v do local clone = k:Clone() local cloneName = clone.Name local text: string = tostring(i) clone.Name = cloneName .. "_" .. text clone.Parent = object.Model local motor6D: Motor6D = Instance.new("Motor6D") motor6D.Part0 = object.Model.PrimaryPart motor6D.Part1 = clone local cFrameNew = CFrame.new local vector3 = Vector3.new(0, 0, n1) motor6D.C0 = cFrameNew(vector3) motor6D.Parent = object.Model.PrimaryPart n1 += 3.533 end end end local currentCameraCFrame: CFrame = CurrentCamera.CFrame local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Exclude raycastParams.FilterDescendantsInstances = { workspace.Debug, object._viewmodel._character, object._viewmodel._viewmodel, workspace.DebugLaser, workspace.Barriers } object._maid:GiveTask(runService.RenderStepped:Connect(function(deltaTime: number) if object._dynamicThumbstick and object._dynamicThumbstick.Enabled then local moveVector = object._dynamicThumbstick.MoveVector local v204 = util.Camera.GetSensitivityMultiplierFromFOV(CurrentCamera.FieldOfView) local n1 = moveVector * v204 * deltaTime local lookVector = CurrentCamera.CFrame.LookVector local v207 = math.asin(lookVector.Y) v204 = math.clamp(n1.Y, v207 + -1.3962634015954636, v207 + 1.3962634015954636) local vector2 = Vector2.new(n1.X, v204) local cFrame = CFrame.new(Vector3.new(0, 0, 0), lookVector) local v210 = CFrame.Angles(0, -vector2.X, 0) local v211 = CFrame.Angles(-vector2.Y, 0, 0) local n2 = v210 * cFrame * v211 cameraController:AddRotation(-n1.X, -n1.Y) end if object.ScopeGui then local currentCameraCFrame2: CFrame = CurrentCamera.CFrame object.Springs.Parallax:Update(deltaTime) object.Springs.ScopeOffset:Update(deltaTime) if object.Aiming then local v214, v215, v216 = (currentCameraCFrame:Inverse() * currentCameraCFrame2):ToOrientation() local vector3 = Vector3.new(v214, v215, v216) object.Springs.Parallax:Shove(vector3 * 25 / deltaTime) local n3 = Vector3.new(object.Springs.Parallax.Position.Y, object.Springs.Parallax.Position.X, 0) + object.Springs.ScopeOffset.Position object.ScopeGui.Parallax.Position = UDim2.new(0.5, n3.X, 0.5, n3.Y) end currentCameraCFrame = currentCameraCFrame2 end end)) return object end for _, v in ipairs(object.Model:GetDescendants()) do if v:IsA("SurfaceGui") then v.Enabled = false end end return object end function module.GetModel(p28, p29) local clone = p28._modelReference:Clone() if p29.Muzzle then local clone2 = replicatedStorage.Attachments:FindFirstChild(p29.Muzzle, true):Clone() local foundChild = clone.PrimaryPart.AttachmentOffsets.Muzzles:FindFirstChild(p29.Muzzle) if not foundChild then local v97 = ("[Rifle]: %* has no AttachmentOffset for %*"):format(clone.Name, p29.Muzzle) error(v97) end if foundChild:FindFirstChild("Scale") then clone2:ScaleTo(foundChild.Scale.Value) end clone2:PivotTo(clone.PrimaryPart.CFrame * foundChild.Value) local weldConstraint: WeldConstraint = Instance.new("WeldConstraint", clone.PrimaryPart) weldConstraint.Part0 = clone.PrimaryPart weldConstraint.Part1 = clone2.PrimaryPart clone2.Parent = clone p28.Configurations.Muzzle = require(clone2.Configuration) p28.Attachments.Muzzle = clone2 end if p29.Sight then local clone3 = replicatedStorage.Attachments.Sights:FindFirstChild(p29.Sight):Clone() local foundChild = clone.PrimaryPart.AttachmentOffsets.Sights:FindFirstChild(p29.Sight) if not foundChild then local v101 = ("[Rifle]: %* has no AttachmentOffset for %*"):format(clone.Name, p29.Sight) error(v101) end if foundChild:FindFirstChild("Scale") then clone3:ScaleTo(foundChild.Scale.Value) end clone3:PivotTo(clone.PrimaryPart.CFrame * foundChild.Value) local weldConstraint: WeldConstraint = Instance.new("WeldConstraint", clone.PrimaryPart) weldConstraint.Part0 = clone.PrimaryPart weldConstraint.Part1 = clone3.PrimaryPart clone3.Parent = clone p28.Configurations.Sight = require(clone3.Configuration) p28.Attachments.Sight = clone3 local cloneName = clone3.Offsets:FindFirstChild(clone.Name) if not cloneName then local v104 = ("[Rifle]: Attachment %* has no CFrame offset value for %*"):format(clone3.Name, clone.Name) error(v104) end clone.Offsets.Aim.Value = cloneName.Value end return clone end local cubic = Enum.EasingStyle.Cubic local exponential = Enum.EasingStyle.Exponential local quart = Enum.EasingStyle.Quart local v31 = Enum.EasingStyle.Exponential function module.CanAim(p30) if v17 and p30._viewmodel and p30._lifetime and p30._lifetime.Alive and fusion.peek(router.State).Name == "Gameplay" and not guiService.MenuIsOpen and not fusion.peek(router.Context.IsTeleporting) then if not p30._inputContext or not p30._inputContext:IsActive() then return false end for _, v in ipairs(fusion.peek(v17.State)) do if v.Blocks and (not v.Screens or not not table.find(v.Screens, "Gameplay")) then return false end end return true end return false end function module.SetAimIntent(p31, p32) if not p31._lifetime or not p31._lifetime.Alive then return end p31.WantsAim = p32 and p31:CanAim() require(replicatedStorage.Common.InputHandler).TouchButtons.Aim.Active:set(p31.WantsAim) if not p31.Reloading and p31.Aiming ~= p31.WantsAim and (not p31.WantsAim or not p31._viewmodel.Debounce) then p31:Aim(p31.WantsAim) end end function module.ClearAimIntent(p33) if not p33._lifetime or not p33._lifetime.Alive then return end p33.Input.HoldingAim = false p33:SetAimIntent(false) end function module.RestoreAimIntent(p34) if not p34._lifetime or not p34._lifetime.Alive then return end if not p34:CanAim() then p34:ClearAimIntent() end if p34.WantsAim then p34:Aim(true) return end p34.LoadedAnimations.Viewmodel.Idle:Play(0.5) end local t2: {[any]: any} = { AnimationTransitionTime = 0.3, PreZoomDelay = 0.15, ZoomInTime = 0.4, ZoomOutTime = 0.25, ScopeUITransitionTime = 0.8, UseProgressiveZoom = true, ZoomCurve = 0.7, AllowZoomCancel = true, SmoothMouseSensitivity = true, AnimationEasing = cubic, ZoomInEasing = exponential, ZoomOutEasing = quart, AimLerpEasing = v31 } function module.Aim(p35, p36, p37) if not p35._lifetime or not p35._lifetime.Alive then return end if p36 and not p35:CanAim() then return end if p36 and p35._viewmodel.Debounce then warn("DEBOUNCED! Cannot aim in while firing.") return end if p35.AimTransition then if p36 == p35.Aiming then return end if p35._aimTween then p35._aimTween:Cancel() p35._aimTween = nil end if p35._sensitivityTween then p35._sensitivityTween:Cancel() p35._sensitivityTween = nil end if not p36 and p35.Aiming then p35._aimCancel:Fire() end end if p35.Reloading and not p37 then return end if p37 then p35.Reloading = true end local _lifetime = p35._lifetime _lifetime.AimRevision = _lifetime.AimRevision + 1 local _lifetimeAimRevision = _lifetime.AimRevision local function isCurrent() return _lifetime.Alive and _lifetime.AimRevision == _lifetimeAimRevision end p35.AimTransition = true if p35._aimConnections then for _, v in ipairs(p35._aimConnections) do v:Disconnect() end end p35._aimConnections = {} local v120 = p35.AimConfig or t2 local inputHandler = require(replicatedStorage.Common.InputHandler) local u123 local connection if p36 then guiService.TouchControlsEnabled = false p35.Aiming = true router.Context.IsScoped:set(true) inputHandler.TouchButtons.ChangeStance.Visible:set(false) inputHandler.TouchButtons.ToggleFlashlight.Visible:set(false) inputHandler.TouchButtons.ToggleSprint.Visible:set(false) inputHandler.TouchButtons.Fire.Visible:set(true) u123 = nil if p35.ScopeGui and p35.Attachments.Sight then local v126, v127 = CurrentCamera:WorldToScreenPoint(p35.Attachments.Sight.PrimaryPart.ScopeLens.WorldPosition) u123 = Vector2.new(v126.X, v126.Y) - CurrentCamera.ViewportSize / 2 end p35.LoadedAnimations.Viewmodel.Idle:Stop(v120.AnimationTransitionTime) p35.LoadedAnimations.Viewmodel.Aim:Play(v120.AnimationTransitionTime) p35.AimLerp:Lerp(1, v120.AnimationTransitionTime, v120.AimLerpEasing, Enum.EasingDirection.Out) connection = true local connection2 = p35._aimCancel:Connect(function() connection = false if p35._aimTween then p35._aimTween:Cancel() p35._aimTween = nil end if p35._sensitivityTween then p35._sensitivityTween:Cancel() p35._sensitivityTween = nil end CurrentCamera.FieldOfView = 70 if connection then p35.AimTransition = false end end) table.insert(p35._aimConnections, connection2) task.spawn(function() if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision or not p35.Aiming or not connection then return end local n1 = 70 / p35.Configurations.Sight.Magnification local sensitivityMultiplier = util.Camera.GetSensitivityMultiplierFromFOV(n1) if v120.UseProgressiveZoom then local timestamp = tick() local currentCameraFieldOfView: number = CurrentCamera.FieldOfView local cameraControllerSensitivityMultiplier = cameraController.SensitivityMultiplier task.wait(v120.PreZoomDelay) if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision or not p35.Aiming or not connection then return end local connection2 = nil connection2 = runService.RenderStepped:Connect(function() if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision or not p35.Aiming or not connection then connection2:Disconnect() return end local timestamp2 = tick() local v240 = math.min((timestamp2 - timestamp - v120.PreZoomDelay) / v120.ZoomInTime, 1) CurrentCamera.FieldOfView = currentCameraFieldOfView + (n1 - currentCameraFieldOfView) * v240 ^ v120.ZoomCurve if v120.SmoothMouseSensitivity then local v241 = math.min(v240 * 1.5, 1) cameraController.SensitivityMultiplier = cameraControllerSensitivityMultiplier + (sensitivityMultiplier - cameraControllerSensitivityMultiplier) * v241 end if v240 >= 1 then connection2:Disconnect() p35.AimTransition = false if not p35.WantsAim then p35:Aim(false) end end end) table.insert(p35._aimConnections, connection2) else task.wait(v120.PreZoomDelay) if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision or not p35.Aiming or not connection then return end connection2 = CurrentCamera local tweenInfo = TweenInfo.new(v120.ZoomInTime, v120.ZoomInEasing, Enum.EasingDirection.Out) p35._aimTween = tweenService:Create(connection2, tweenInfo, { FieldOfView = n1 }) if v120.SmoothMouseSensitivity then local v226 = cameraController.SensitivityMultiplier local tweenInfo2 = TweenInfo.new(v120.ZoomInTime * 0.8, Enum.EasingStyle.Quad) connection2 = { value = v226 } p35._sensitivityTween = tweenService:Create(connection2, tweenInfo2, { value = sensitivityMultiplier }) connection2 = p35._sensitivityTween:GetPropertyChangedSignal("value"):Connect(function() if _lifetime.Alive and _lifetime.AimRevision == _lifetimeAimRevision then cameraController.SensitivityMultiplier = p35._sensitivityTween.value end end) table.insert(p35._aimConnections, connection2) p35._sensitivityTween:Play() else cameraController.SensitivityMultiplier = sensitivityMultiplier end connection2 = p35._aimTween.Completed:Connect(function() if _lifetime.Alive and _lifetime.AimRevision == _lifetimeAimRevision and p35.Aiming then p35.AimTransition = false if not p35.WantsAim then p35:Aim(false) end end end) table.insert(p35._aimConnections, connection2) p35._aimTween:Play() end if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision then elseif p35.ScopeGui then for _, v in ipairs(collectionService:GetTagged("HideOnAim")) do v.Visible = false end p35.ScopeGui.Enabled = true p35.Springs.ScopeOffset.Position = Vector3.new(u123.X, u123.Y, 0) updateDynamicThumbstick(p35, p35._replica.Data.Settings.ThumbstickAim) if script.HideWeaponWhenAiming.Value then hideViewmodel(p35) end if p35._thermalConnection then p35._thermalConnection:Disconnect() end if p35.Configurations.Sight.IsThermal and #collectionService:GetTagged("ThermalEffect") == 0 then game.Lighting:FindFirstChildOfClass("ColorCorrectionEffect").Enabled = false local clone = p35.Attachments.Sight:FindFirstChildOfClass("ColorCorrectionEffect"):Clone() clone.Enabled = true clone.Parent = game.Lighting collectionService:AddTag(clone, "ThermalEffect") local function applyEffect(parent) local clone4 = p35.Attachments.Sight:FindFirstChildOfClass("Highlight"):Clone() clone4.Parent = parent clone4.Enabled = true collectionService:AddTag(clone4, "ThermalEffect") end for _, v in ipairs(collectionService:GetTagged("Animal")) do if v.PrimaryPart and (v.PrimaryPart.Position - CurrentCamera.CFrame.Position).Magnitude < 1000 then local clone5 = p35.Attachments.Sight:FindFirstChildOfClass("Highlight"):Clone() clone5.Parent = v clone5.Enabled = true collectionService:AddTag(clone5, "ThermalEffect") end end p35._thermalConnection = collectionService:GetInstanceAddedSignal("Animal"):Connect(function(parent) local clone6 = p35.Attachments.Sight:FindFirstChildOfClass("Highlight"):Clone() clone6.Parent = parent clone6.Enabled = true collectionService:AddTag(clone6, "ThermalEffect") end) end if p35.Configurations.Sight.IsRangefinder then local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Exclude raycastParams.FilterDescendantsInstances = { p35._viewmodel._viewmodel, p35._viewmodel._character, workspace.Barriers, workspace.LocationRegions, workspace.AnimalNodes, workspace.VehicleSpawners, workspace.Debug, workspace.DebugLaser } table.insert(p35._aimConnections, runService.RenderStepped:Connect(function(deltaTime: number) local v247 = workspace:Raycast(CurrentCamera.CFrame.Position, CurrentCamera.CFrame.LookVector * 3567.8571428571427, raycastParams) local n1 = 3567.8571428571427 if v247 then n1 = v247.Distance end local getDistance = p35._measurementModule.GetDistance local rounded = math.round(n1 * 0.28) local v251, v252 = getDistance(rounded, 0, false, { Imperial = "yd", Metric = "m" }) local v253 = math.min(v251, 999) p35.ScopeGui.DistanceLabel.Text = ("%* %*"):format(math.round(v253), v252) end)) end end end) if p35._viewmodel.Proning then p35._viewmodel.LoadedAnimations.Character.Crawl:Stop() p35.LoadedAnimations.Character.ProneAim:Play() elseif p35._viewmodel.Crouching then p35._viewmodel.LoadedAnimations.Character.CrouchWalk:Stop() p35.LoadedAnimations.Character.CrouchAim:Play() else p35._viewmodel.LoadedAnimations.Character.Idle:Stop() p35.LoadedAnimations.Character.StandingAim:Play() end return end u123 = p35._dynamicThumbstick if u123 then u123 = p35._dynamicThumbstick u123:Enable(false) end u123 = p35._aimCancel u123:Fire() u123 = p35._aimTween if u123 then u123 = p35._aimTween u123:Cancel() u123 = nil p35._aimTween = u123 end u123 = p35._sensitivityTween if u123 then u123 = p35._sensitivityTween u123:Cancel() u123 = nil p35._sensitivityTween = u123 end u123 = tweenService local tweenInfo = TweenInfo.new(v120.ZoomOutTime, v120.ZoomOutEasing, Enum.EasingDirection.Out) u123 = u123:Create(CurrentCamera, tweenInfo, { FieldOfView = 70 }) p35._aimTween = u123 u123 = cameraController u123 = u123.SensitivityMultiplier connection = v120.SmoothMouseSensitivity if connection then connection = math.abs connection = connection(u123 - 1) end if not connection or not (connection > 0.01) then connection = cameraController connection.SensitivityMultiplier = 1 else connection = task.spawn connection(function() local n1 = 0 while n1 < v120.ZoomOutTime * 0.7 and _lifetime.Alive and _lifetime.AimRevision == _lifetimeAimRevision do local v237 = runService.RenderStepped:Wait() n1 += v237 if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision then return end cameraController.SensitivityMultiplier = u123 + (1 - u123) * (n1 / (v120.ZoomOutTime * 0.7)) end if _lifetime.Alive and _lifetime.AimRevision == _lifetimeAimRevision then cameraController.SensitivityMultiplier = 1 end end) end connection = p35._aimTween connection = connection.Completed connection = connection:Connect(function() if _lifetime.Alive and _lifetime.AimRevision == _lifetimeAimRevision then p35.AimTransition = false end end) table.insert(p35._aimConnections, connection) p35._aimTween:Play() showViewmodel(p35) task.spawn(function() if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision then return end task.wait(0.05) if not _lifetime.Alive or _lifetime.AimRevision ~= _lifetimeAimRevision then elseif p35.ScopeGui and not p35.Aiming then p35.ScopeGui.Enabled = false end end) for _, v in ipairs(collectionService:GetTagged("HideOnAim")) do v.Visible = true end p35.LoadedAnimations.Viewmodel.Aim:Stop(v120.AnimationTransitionTime) p35.LoadedAnimations.Viewmodel.Idle:Play(v120.AnimationTransitionTime) p35.AimLerp:Lerp(0, v120.AnimationTransitionTime, v120.AimLerpEasing, Enum.EasingDirection.In) if p35._viewmodel.Proning then p35.LoadedAnimations.Character.ProneAim:Stop() p35._viewmodel.LoadedAnimations.Character.Crawl:Play() p35._viewmodel:_startAnimationCycle(p35._viewmodel.LoadedAnimations.Character.Crawl) elseif p35._viewmodel.Crouching then p35.LoadedAnimations.Character.CrouchAim:Stop() p35._viewmodel.LoadedAnimations.Character.CrouchWalk:Play() p35._viewmodel:_startAnimationCycle(p35._viewmodel.LoadedAnimations.Character.CrouchWalk) else p35.LoadedAnimations.Character.StandingAim:Stop() p35._viewmodel.LoadedAnimations.Character.Idle:Play() end if p35._thermalConnection then p35._thermalConnection:Disconnect() end for _, v in ipairs(collectionService:GetTagged("ThermalEffect")) do v:Destroy() end game.Lighting:FindFirstChildOfClass("ColorCorrectionEffect").Enabled = true p35.Aiming = false router.Context.IsScoped:set(false) guiService.TouchControlsEnabled = true inputHandler.TouchButtons.ChangeStance.Visible:set(true) inputHandler.TouchButtons.ToggleFlashlight.Visible:set(true) inputHandler.TouchButtons.ToggleSprint.Visible:set(true) inputHandler.TouchButtons.Fire.Visible:set(false) if p35.NeedsLoading and not p37 then p35.NeedsLoading = false task.defer(function() if _lifetime.Alive then p35:Load() end end) elseif p35.NeedsReloading and not p37 then p35.NeedsReloading = false task.defer(function() if _lifetime.Alive then p35:Reload() end end) end end local random = Random.new() local function RandomVectorOffset(p41, p42) local cFrame = CFrame.new(Vector3.new(), p41) local v137 = CFrame.Angles(0, 0, random:NextNumber(0, 6.283185307179586)) local cFrameAngles = CFrame.Angles local cosine = math.cos(p42) local v140 = random:NextNumber(cosine, 1) local v141 = math.acos(v140) local v142 = cFrameAngles(v141, 0, 0) return (cFrame * v137 * v142).LookVector end function module.IsReady(p43) if p43.Aiming then return false end if p43.Reloading then return false end return true end function module.Fire(p44) local _lifetime = p44._lifetime if not _lifetime or not _lifetime.Alive or not p44:CanAim() then return end if p44._viewmodel.Debounce then return end if not p44.Aiming then return end if p44.Reloading then return end if (p44.BulletsInMagazine or 0) < 1 then return p44:Reload() end if not p44.Loaded then p44:Load() return end p44._viewmodel.Debounce = true if p44.LoadedAnimations.Viewmodel.Fire then p44.LoadedAnimations.Viewmodel.Fire:Play() end local barrelAttachment = p44.Model.PrimaryPart.BarrelAttachment local v147 = ammunition[p44.Ammunition] local n1 = 3.141592653589793 * (v147.Diameter / 2) ^ 2 * 0.000001 local v149 = p44.Model.PrimaryPart.FireSounds:GetChildren() local randomNumber = math.random(1, #v149) local v151 = v149[randomNumber] v149 = sound.new(v151.SoundId, p44.Model.PrimaryPart.Position, { ApplyDistanceEffects = false, ConnectToAnalyzer = true, Volume = v151.Volume }) if p44.Configurations.Muzzle and p44.Configurations.Muzzle.Type == "Suppressor" then for _, v in ipairs(p44.Attachments.Muzzle.SoundEffects:GetChildren()) do v149:AddSoundEffect(v:Clone()) end end v149:Play() local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Exclude raycastParams.FilterDescendantsInstances = { workspace.Debug, p44._viewmodel._character, p44._viewmodel._viewmodel, workspace.DebugLaser, workspace.Barriers, workspace.LocationRegions } v149 = workspace:Raycast(CurrentCamera.CFrame.Position, CurrentCamera.CFrame.LookVector * 1500, raycastParams) local v155 = if v149 then (v149.Position - barrelAttachment.WorldPosition).Unit else (CurrentCamera.CFrame.Position + CurrentCamera.CFrame.LookVector * 1500 - barrelAttachment.WorldPosition).Unit v151 = {} for k, v in pairs(p44.Attachments) do v151[k] = v.Name end p44.BulletsInMagazine = p44.BulletsInMagazine - 1 p44:_updateGui() if p44.Configurations.Class == "Shotgun" and v147.NumberOfPellets > 1 then local t3: {[any]: any} = {} for _ = 1, v147.NumberOfPellets do local v160 = RandomVectorOffset(v155, 0.035) table.insert(t3, v160) end projectileController:FireBatch(barrelAttachment.WorldPosition, t3, p44.MuzzleVelocity / 0.28, { MaxHits = 1, FireProjectileHit = true, BulletProperties = { Mass = v147.Mass, DragCoefficient = v147.DragCoefficient, Diameter = v147.Diameter, Type = v147.Type, Name = p44.Ammunition, Tracer = if v147.Tracer == true then true else false, CreateImpactEffect = if v147.CreateImpactEffect == nil then true else v147.CreateImpactEffect }, Attachments = v151, CrossSectionalArea = n1, WeaponModel = p44._modelReference }) else projectileController:Fire(barrelAttachment.WorldPosition, v155, p44.MuzzleVelocity / 0.28, { MaxHits = 2, FireProjectileHit = true, BulletProperties = { Mass = v147.Mass, DragCoefficient = v147.DragCoefficient, Diameter = v147.Diameter, Type = v147.Type, Name = p44.Ammunition, Tracer = if v147.Tracer == true then true else false, CreateImpactEffect = if v147.CreateImpactEffect == nil then true else v147.CreateImpactEffect }, Attachments = v151, CrossSectionalArea = n1, WeaponModel = p44._modelReference }) end local randomNumber2 = math.random(-0.15, 0.15) local randomNumber3 = math.random(-2.5, 2.5) local v163 = math.rad(randomNumber2) local v164 = math.rad(p44.VerticalRecoil) cameraController:AddRotation(v163, v164) local _recoil = p44._viewmodel.Springs._recoil local vector3 = Vector3.new(p44.VerticalRecoil * 1.5, randomNumber2, randomNumber3) _recoil:Shove(vector3 * 90 * p44._viewmodel._framerate) if p44.FireRate then task.wait(60 / p44.FireRate) end if not _lifetime.Alive then return end p44._viewmodel.Debounce = false p44.Loaded = not p44.LoadBetweenRounds if not p44.Loaded then p44.NeedsLoading = true end if p44.AutomaticReloadAfterShot then p44.NeedsReloading = true end if p44.Aiming ~= p44.WantsAim then p44:SetAimIntent(p44.WantsAim) end end function module._updateGui(p45) if not p45.GunGui or not p45.GunGui.Parent then return end local weaponStats = p45.GunGui:FindFirstChild("WeaponStats") if not weaponStats then return end local v169 = p45._replica and p45._replica.Data and p45._replica.Data.Ammunition and p45._replica.Data.Ammunition[p45.Ammunition] or 0 local v170 = math.clamp(p45.BulletsInMagazine or 0, 0, p45.MagazineCapacity) local v171 = math.max(v169 - v170, 0) if weaponStats:FindFirstChild("TotalAmmoLabel") then weaponStats.TotalAmmoLabel.Text = tostring(v171) end if weaponStats:FindFirstChild("CurrentAmmoLabel") then weaponStats.CurrentAmmoLabel.Text = tostring(v170) end end function module.Reload(p46) local _lifetime = p46._lifetime if not _lifetime or not _lifetime.Alive then elseif not p46._viewmodel.Debounce and not p46.Reloading then local ammunition = p46.Ammunition local v175 = p46.BulletsInMagazine or 0 local v176 = math.max((p46._replica.Data.Ammunition[ammunition] or 0) - v175, 0) if v175 >= p46.MagazineCapacity then return end if v176 <= 0 then return end p46.NeedsReloading = false if p46.Aiming then p46:Aim(false, true) end p46.Reloading = true p46.LoadedAnimations.Viewmodel.Idle:Stop() local v177 = math.min(p46.MagazineCapacity - v175, v176) if v177 <= 0 then p46.Reloading = false p46.LoadedAnimations.Viewmodel.Idle:Play(0.5) return end if p46.Configurations.ReloadSequence then print("[Rifle]: Playing animation sequence") p46.LoadedAnimations.Viewmodel.ReloadBegin:Play() p46.LoadedAnimations.Viewmodel.ReloadBegin.Stopped:Wait() if not _lifetime.Alive then return end p46.LoadedAnimations.Viewmodel.ReloadLoop:Play() local connection = p46.LoadedAnimations.Viewmodel.ReloadLoop.DidLoop:Connect(function() if not _lifetime.Alive then return end local v238 = p46 v238.BulletsInMagazine = v238.BulletsInMagazine + 1 if p46.Input.HoldingAim then p46.LoadedAnimations.Viewmodel.ReloadLoop:Stop(0.5) return end if p46._replica.Data.Ammunition[p46.Ammunition] - p46.BulletsInMagazine < 1 then p46.LoadedAnimations.Viewmodel.ReloadLoop:Stop(0.5) return end if p46.BulletsInMagazine >= p46.MagazineCapacity then p46.LoadedAnimations.Viewmodel.ReloadLoop:Stop(0.5) return end p46:_updateGui() end) p46._reloadLoopConnection = connection p46.LoadedAnimations.Viewmodel.ReloadLoop.Stopped:Wait() connection:Disconnect() if not _lifetime.Alive then return end p46._reloadLoopConnection = nil else print("[Rifle]: Playing reload animation") p46.LoadedAnimations.Viewmodel.Reload:Play() task.wait(p46.LoadedAnimations.Viewmodel.Reload.Length * 0.8) if not _lifetime.Alive then return end p46.BulletsInMagazine = math.min(v175 + v177, p46.MagazineCapacity) end p46.Loaded = true p46.NeedsLoading = false p46:_updateGui() p46.Reloading = false p46:RestoreAimIntent() return end end function module.Load(p47) local _lifetime = p47._lifetime if not _lifetime or not _lifetime.Alive then return end if p47._viewmodel.Debounce then return end if p47.Reloading then return end if p47.Loaded then return end p47.NeedsLoading = false if p47.Aiming then p47:Aim(false, true) end p47.Reloading = true p47.LoadedAnimations.Viewmodel.Idle:Stop() p47.LoadedAnimations.Viewmodel.Load:Play() task.wait(p47.LoadedAnimations.Viewmodel.Load.Length * 0.8) if not _lifetime.Alive then return end p47.Reloading = false p47.Loaded = true p47:RestoreAimIntent() end function module.Destroy(p48) p48.WantsAim = false p48._lifetime.Alive = false if p48._reloadLoopConnection then p48._reloadLoopConnection:Disconnect() end p48._aimCancel:Fire() for _, v in ipairs(p48._aimConnections or {}) do v:Disconnect() end if p48._aimTween then p48._aimTween:Cancel() end if p48._sensitivityTween then p48._sensitivityTween:Cancel() end if p48._viewmodel then require(replicatedStorage.Common.InputHandler).TouchButtons.Aim.Active:set(false) guiService.TouchControlsEnabled = true cameraController.SensitivityMultiplier = 1 CurrentCamera.FieldOfView = 70 showViewmodel(p48) end if p48._thermalConnection then p48._thermalConnection:Disconnect() end for _, v in ipairs(collectionService:GetTagged("ThermalEffect")) do v:Destroy() end game.Lighting:FindFirstChildOfClass("ColorCorrectionEffect").Enabled = true p48._maid:Destroy() if p48.Aiming then for _, v in ipairs(collectionService:GetTagged("HideOnAim")) do v.Visible = true end router.Context.IsScoped:set(false) end setmetatable(p48, nil) table.clear(p48) table.freeze(p48) end return module