-
Notifications
You must be signed in to change notification settings - Fork 1
/
bad_business_silent_aim.lua
97 lines (76 loc) · 4.71 KB
/
bad_business_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
--// Setup & services.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
if not shared.SilentAim then --// If the table doesn't exist. Create one.
shared.SilentAim = {
Enabled = true,
HeadshotChance = 100
}
end
--// Main script.
--// Of course you could just do require(game:GetService("ReplicatedStorage"):WaitForChild("TS")), but why do it the easy way?
local TS = nil
for Index, Value in pairs(getgc(true)) do --// Looping through the garbage collection.
if typeof(Value) == "table" and rawget(Value, "InitProjectile") then --// Seeing if we can find the Projectiles table by searching for the "InitProjectile" function that is paired to said table.
if Value.TS then --// If it has the game's main module in it then we successfully found the game's main module.
TS = Value.TS
break
end
end
end
local function OnClientTeam(Player) --// Checking if the player we are looking for is on the client's (your) team using in-game functions.
if TS.Teams:ArePlayersFriendly(Player, LocalPlayer) then
return true
end
return false
end
local function GetHeadPart(Player) --// Getting the head part of a player.
local Character = TS.Characters:GetCharacter(Player)
local Body = (Character and Character:FindFirstChild("Body"))
if Character and Body then
return Body:FindFirstChild("Head")
end
end
local function GetClosestPlayerCharacterToCursor()
local ClosestPlayer = nil
local FarthestDistance = math.huge
for Index, Player in pairs(Players:GetPlayers()) do --// Loop through all the players.
if Player == LocalPlayer then continue end --// Skip over this iteration if it is the Clients.
if OnClientTeam(Player) then continue end --// Skip over this iteration if the player is on the client's team.
local HeadPart = GetHeadPart(Player)
if HeadPart then
local HeadPosition, OnScreen = Workspace.CurrentCamera:WorldToViewportPoint(HeadPart.Position) --// Converting the 3D position to a screen position to make it easier.
if OnScreen then --// Check if they are visible/on screen in the roblox window area.
local MouseDistanceFromPlayer = (Vector2.new(HeadPosition.X, HeadPosition.Y) - UserInputService:GetMouseLocation()).Magnitude --// Check the mouse distance from the player.
if MouseDistanceFromPlayer < FarthestDistance then
FarthestDistance = MouseDistanceFromPlayer --// Make the farthest distance the mouse distance.
ClosestPlayer = Player --// Closest player is the player iteration we are on for now, may change later on.
end
end
end
end
return TS.Characters:GetCharacter(ClosestPlayer) --// Return the player's character.
end
local OldFireProjectile = TS.Projectiles.InitProjectile --// Making a backup of the old function so we can use it to spoof later on.
TS.Projectiles.InitProjectile = function(self, ...) --// I can't explain self well, but in this situation it is just the Projectiles table. Hooking the function.
local Arguments = {...} --// Converting the function arguments to a table.
if shared.SilentAim.Enabled and Arguments[4] == LocalPlayer then
local ClosestPlayer = GetClosestPlayerCharacterToCursor()
local HeadshotChance = math.random(shared.SilentAim.HeadshotChance, 100)
--// Reference: https://coasts.cool/uploads/zo0BmqjIm0TBlmsy1Mkn.png
--// Position: Arguments[2]
--// Velocity: Arguments[3]
if ClosestPlayer and (ClosestPlayer.Health.Value > 0) then --// Check if it returned a player and the player is alive.
if HeadshotChance == 100 then --// If the random number hits 100 we goto the head because it got the top number.
Arguments[2] = (ClosestPlayer.Hitbox.Head.Position - Arguments[3])
else
Arguments[2] = (ClosestPlayer.Hitbox.Chest.Position - Arguments[3]) --// If not, we will hit at their chest.
end
--// Subtracting with the velocity to get the exact position to hit on the player's head.
--// From google: Velocity is the rate at which the position changes. The average velocity is the displacement or position change (a vector quantity) per time ratio.
end
end
return OldFireProjectile(self, unpack(Arguments)) --// Unpacking the arguments. Basically replcaing parts of the game's fired arguments with our spoofed ones.
end