-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwashington_dc_silent_aim.lua
60 lines (48 loc) · 1.89 KB
/
washington_dc_silent_aim.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = game:GetService("Players").LocalPlayer
local Players = game:GetService("Players")
local Camera = Workspace.CurrentCamera
local function GetClosestPlayer()
local ClosestPlayer = nil
local FarthestDistance = math.huge
for Index, Player in pairs(Players:GetPlayers()) do
if Player ~= LocalPlayer and Player.Character then
local HumanoidRootPart = Player.Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
local RootScreenPosition, OnScreen = Camera:WorldToViewportPoint(HumanoidRootPart.Position)
if OnScreen then
local MouseDistanceFromPlayer = (Vector2.new(RootScreenPosition.X, RootScreenPosition.Y) - UserInputService:GetMouseLocation()).Magnitude
if MouseDistanceFromPlayer < FarthestDistance then
FarthestDistance = MouseDistanceFromPlayer
ClosestPlayer = Player
end
end
end
end
end
return ClosestPlayer
end
local FireFunction = nil
for Index, Value in pairs(getgc(true)) do
if typeof(Value) == "table" and rawget(Value, "Fire") then
if Value.ToggleCrouch and Value.UpdateAmmoGui then
FireFunction = Value.Fire
break
end
end
end
if not FireFunction then
LocalPlayer:Kick("Failed to get required function(s).")
return
end
local OldFireFunction = nil
OldFireFunction = hookfunction(FireFunction, function(...)
local Arguments = {...}
if shared.SilentAim then
local ClosestPlayer = GetClosestPlayer()
if ClosestPlayer and ClosestPlayer.Character then
Arguments[2] = ClosestPlayer.Character.Head.Position
end
end
return OldFireFunction(unpack(Arguments))
end)