
KeylessUniversal

local Bullets = require(game:GetService("ReplicatedStorage").Client.Libraries.Bullets)
local originalFire = Bullets.Fire
local TARGET_MAX_DIST = 500
function Bullets.Fire(self, playerController, weaponInstance, weaponData, origin, direction, shotId)
local newDirection = direction
local localPlayer = game.Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local camera = workspace.CurrentCamera
local ray = camera:ScreenPointToRay(mouse.X, mouse.Y)
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {localPlayer.Character}
local rayResult = workspace:Raycast(ray.Origin, ray.Direction * 1000, raycastParams)
local hitPoint = rayResult and rayResult.Position or ray.Origin + ray.Direction * 1000
local closestHRP = nil
local closestDist = math.huge
for _, model in ipairs(workspace.Characters:GetChildren()) do
local hrp = model:FindFirstChild("HumanoidRootPart")
if hrp and model ~= localPlayer.Character then
local dist = (hrp.Position - hitPoint).Magnitude
if dist < closestDist then
closestDist = dist
closestHRP = hrp
end
end
end
for _, model in ipairs(workspace.Zombies:GetChildren()) do
local hrp = model:FindFirstChild("HumanoidRootPart")
if hrp then
local dist = (hrp.Position - hitPoint).Magnitude
if dist < closestDist then
closestDist = dist
closestHRP = hrp
end
end
end
if closestHRP and closestDist < TARGET_MAX_DIST then
newDirection = (closestHRP.Position - origin).Unit
end
return originalFire(self, playerController, weaponInstance, weaponData, origin, newDirection, shotId)
endNo comments yet for this script.



