--[[ If you enjoy the script, please consider liking the post. It helps motivate me to release more open-source scripts and keep existing ones updated. ]] local StarterGui = game:GetService("StarterGui") local function notify(title, message, duration) local details = { Title = title, Text = message, Duration = duration, Button1 = "OK", } for _ = 1, 8 do if pcall(StarterGui.SetCore, StarterGui, "SendNotification", details) then return end task.wait(0.25) end warn(title .. ": " .. message) end local environmentGetter = getgenv local executorDebug = debug local missing = {} if type(environmentGetter) ~= "function" then table.insert(missing, "getgenv") end for _, name in { "getupvalues", "getupvalue", "setupvalue" } do if type(executorDebug) ~= "table" or type(executorDebug[name]) ~= "function" then table.insert(missing, "debug." .. name) end end if #missing > 0 then notify("Executor APIs Missing", "Required: " .. table.concat(missing, ", "), 20) return end local environmentOk, environment = pcall(function() return environmentGetter() end) if not environmentOk then notify("Executor APIs Missing", "getgenv() failed: " .. tostring(environment), 20) return end if type(environment) ~= "table" then notify("Executor APIs Missing", "getgenv() did not return a table.", 20) return end local upvalues = executorDebug.getupvalues local getupvalue = executorDebug.getupvalue local setupvalue = executorDebug.setupvalue local previous = environment.__aimSession if previous then assert(type(previous.unload) == "function", "Existing shooting hook cannot be unloaded") local success, reason = pcall(previous.unload, true) assert(success and environment.__aimSession ~= previous, "Could not unload the existing shooting hook: " .. tostring(reason)) end local ReplicatedStorage = game:GetService("ReplicatedStorage") local UserInputService = game:GetService("UserInputService") local ClientShootable = require(ReplicatedStorage.Client.CombatController.ClientComponent.ClientShootableComponent) local Entities = require(ReplicatedStorage.Remote.EntityService) local HumanoidEntity = require(ReplicatedStorage.Remote.EntityService.Entity.HumanoidEntity) local Collision = require(ReplicatedStorage.Constant).Collision local Combat = require(ReplicatedStorage.Config.Config).Combat local originalShoot = ClientShootable.Shoot local localShoot = ClientShootable.LocalShoot assert(type(originalShoot) == "function" and type(localShoot) == "function", "The game's shooting functions are unavailable") local originIndex, originalOrigin for index, value in upvalues(originalShoot) do if type(value) == "function" then assert(originIndex == nil, "The weapon has more than one origin function") originIndex, originalOrigin = index, value end end assert(originIndex ~= nil, "The weapon's origin function was not found") local localOriginMatches = 0 for _, value in upvalues(localShoot) do if value == originalOrigin then localOriginMatches += 1 end end assert(localOriginMatches == 1, "LocalShoot uses a different combat origin") local CONE_DOT = math.cos(math.rad(15)) local rayParams = RaycastParams.new() rayParams.FilterType = Enum.RaycastFilterType.Exclude rayParams.RespectCanCollide = false local state = { active = true, enabled = true, selectedEntity = nil, selectedAt = -math.huge, preparedShot = nil, connections = {}, reportedSelectionError = false, } local function visiblePoint(entity, origin, view) local model = entity:GetModel() if not model or not model:IsDescendantOf(workspace) then return nil end local candidates = { entity:GetBodyPart(), entity:GetRootPart(), model:FindFirstChild("Head", true), } for _, part in candidates do if part and part:IsA("BasePart") then local offset = part.Position - origin local distance = offset.Magnitude if distance > 0.01 and distance <= Combat.BulletMaxDistance and view:Dot(offset.Unit) >= CONE_DOT then local obstruction = workspace:Raycast(origin, offset, rayParams) if not obstruction or obstruction.Instance:IsDescendantOf(model) then return part.Position, distance, part end end end end return nil end local function acquireTarget(origin, view) local self = Entities.GetLocalEntity() if not self or not self:IsAlive() then return nil end local group = self:GetCollision(Collision.Attack) if type(group) ~= "string" then return nil end rayParams.CollisionGroup = group local character = self:GetWorkspaceRoot() rayParams.FilterDescendantsInstances = character and { character } or {} local function isHostile(entity) return entity ~= self and HumanoidEntity:is(entity) and entity:IsAlive() and not self:IsFriendly(entity) end if state.selectedEntity and os.clock() - state.selectedAt <= 0.22 and isHostile(state.selectedEntity) then local point, distance, part = visiblePoint(state.selectedEntity, origin, view) if point then return state.selectedEntity, point, distance, part end end local closestEntity, closestPoint, closestDistance, closestPart closestDistance = Combat.BulletMaxDistance for _, entity in Entities.Entity.GetAll() do if isHostile(entity) then local point, distance, part = visiblePoint(entity, origin, view) if point and distance < closestDistance then closestEntity, closestPoint, closestDistance, closestPart = entity, point, distance, part end end end return closestEntity, closestPoint, closestDistance, closestPart end local function reportSelectionError(reason) if not state.reportedSelectionError then state.reportedSelectionError = true warn("Target selection failed: " .. tostring(reason)) end end local function redirectedOrigin(...) local origin, detectedAt, cameraData = originalOrigin(...) if not (state.active and state.enabled and typeof(origin) == "CFrame") then return origin, detectedAt, cameraData end if state.preparedShot == false then return origin, detectedAt, cameraData end local entity, point if state.preparedShot then entity, point = state.preparedShot.entity, state.preparedShot.point else local success, selected, selectedPoint = pcall(acquireTarget, origin.Position, origin.LookVector) if not success then reportSelectionError(selected) return origin, detectedAt, cameraData end entity, point = selected, selectedPoint end if not point then return origin, detectedAt, cameraData end local offset = point - origin.Position if offset.Magnitude <= 0.001 or origin.LookVector:Dot(offset.Unit) < CONE_DOT then return origin, detectedAt, cameraData end state.selectedEntity = entity state.selectedAt = os.clock() return CFrame.lookAt(origin.Position, point), detectedAt, cameraData end local function runOriginalShoot(component, start, direction, context, prepared) state.preparedShot = prepared local success, result = pcall(originalShoot, component, start, direction, context) state.preparedShot = nil if not success then error(result, 0) end return result end local function shootWithTarget(component, start, direction, context) if not (state.active and state.enabled) then return originalShoot(component, start, direction, context) end local success, origin = pcall(originalOrigin) if not success or typeof(origin) ~= "CFrame" then return runOriginalShoot(component, start, direction, context, false) end local selected, entity, point, _, part = pcall(acquireTarget, origin.Position, origin.LookVector) if not selected then reportSelectionError(entity) return runOriginalShoot(component, start, direction, context, false) end if not entity or not point then return runOriginalShoot(component, start, direction, context, false) end local pivot = entity:GetPivot(true) local offset = point - origin.Position if not pivot or offset.Magnitude <= 0.001 or origin.LookVector:Dot(offset.Unit) < CONE_DOT then return runOriginalShoot(component, start, direction, context, false) end local shotContext = context or {} shotContext.Target = entity.Instance shotContext.TargetPos = pivot:PointToObjectSpace(point) shotContext.TargetHeadshot = part ~= nil and part.Name == "Head" return runOriginalShoot(component, start, direction, shotContext, { entity = entity, point = point }) end function state.unload(silent) if not state.active then return end state.active = false state.enabled = false for index = #state.connections, 1, -1 do state.connections[index]:Disconnect() state.connections[index] = nil end if ClientShootable.Shoot == shootWithTarget then ClientShootable.Shoot = originalShoot else warn("Shoot changed externally; original function was not restored") end if getupvalue(originalShoot, originIndex) == redirectedOrigin then setupvalue(originalShoot, originIndex, originalOrigin) else warn("Combat origin changed externally; original function was not restored") end if environment.__aimSession == state then environment.__aimSession = nil end if not silent then notify("Silent Aim", "Unloaded", 5) end end setupvalue(originalShoot, originIndex, redirectedOrigin) assert(getupvalue(originalShoot, originIndex) == redirectedOrigin, "Could not install the combat origin redirect") ClientShootable.Shoot = shootWithTarget environment.__aimSession = state state.connections[1] = UserInputService.InputBegan:Connect(function(input, processed) if processed or UserInputService:GetFocusedTextBox() then return end if input.KeyCode == Enum.KeyCode.RightShift then state.enabled = not state.enabled notify("Silent Aim", state.enabled and "Enabled" or "Disabled", 4) elseif input.KeyCode == Enum.KeyCode.End then state.unload() end end) notify("The Controls", "Right Shift - toggle silent aim\nEnd - unload the script", 20)