-
Notifications
You must be signed in to change notification settings - Fork 0
/
idk
438 lines (364 loc) · 11.9 KB
/
idk
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
if getgenv().Aiming then return getgenv().Aiming end
-- // Services
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local GuiService = game:GetService("GuiService")
local RunService = game:GetService("RunService")
-- // Vars
local Heartbeat = RunService.Heartbeat
local LocalPlayer = Players.LocalPlayer
local CurrentCamera = Workspace.CurrentCamera
local Mouse = LocalPlayer:GetMouse()
-- // Optimisation Vars (ugly)
local Drawingnew = Drawing.new
local Color3fromRGB = Color3.fromRGB
local Vector2new = Vector2.new
local GetGuiInset = GuiService.GetGuiInset
local Randomnew = Random.new
local mathfloor = math.floor
local CharacterAdded = LocalPlayer.CharacterAdded
local CharacterAddedWait = CharacterAdded.Wait
local WorldToViewportPoint = CurrentCamera.WorldToViewportPoint
local RaycastParamsnew = RaycastParams.new
local EnumRaycastFilterTypeBlacklist = Enum.RaycastFilterType.Blacklist
local Raycast = Workspace.Raycast
local GetPlayers = Players.GetPlayers
local Instancenew = Instance.new
local IsDescendantOf = Instancenew("Part").IsDescendantOf
local FindFirstChildWhichIsA = Instancenew("Part").FindFirstChildWhichIsA
local FindFirstChild = Instancenew("Part").FindFirstChild
local tableremove = table.remove
local tableinsert = table.insert
-- // Silent Aim Vars
getgenv().Aiming = {
Enabled = true,
ShowFOV = true,
FOV = 119,
FOVSides = 300,
FOVColour = Color3fromRGB(255,0,0),
VisibleCheck = true,
HitChance = 110,
Selected = nil,
SelectedPart = nil,
TargetPart = {"Head", "UpperTorso", "HumanoidRootPart", "LowerTorso"},
Ignored = {
Teams = {
{
Team = LocalPlayer.Team,
TeamColor = LocalPlayer.TeamColor,
},
},
Players = {
LocalPlayer,
91318356
}
}
}
local Aiming = getgenv().Aiming
-- // Create circle
local circle = Drawingnew("Circle")
circle.Transparency = 1
circle.Thickness = 2
circle.Color = Aiming.FOVColour
circle.Filled = false
Aiming.FOVCircle = circle
-- // Update
function Aiming.UpdateFOV()
-- // Make sure the circle exists
if not (circle) then
return
end
-- // Set Circle Properties
circle.Visible = Aiming.ShowFOV
circle.Radius = (Aiming.FOV * 3)
circle.Position = Vector2new(Mouse.X, Mouse.Y + GetGuiInset(GuiService).Y)
circle.NumSides = Aiming.FOVSides
circle.Color = Aiming.FOVColour
-- // Return circle
return circle
end
-- // Custom Functions
local CalcChance = function(percentage)
-- // Floor the percentage
percentage = mathfloor(percentage)
-- // Get the chance
local chance = mathfloor(Randomnew().NextNumber(Randomnew(), 0, 1) * 100) / 100
-- // Return
return chance <= percentage / 100
end
-- // Customisable Checking Functions: Is a part visible
function Aiming.IsPartVisible(Part, PartDescendant)
-- // Vars
local Character = LocalPlayer.Character or CharacterAddedWait(CharacterAdded)
local Origin = CurrentCamera.CFrame.Position
local _, OnScreen = WorldToViewportPoint(CurrentCamera, Part.Position)
-- //
if (OnScreen) then
-- // Vars
local raycastParams = RaycastParamsnew()
raycastParams.FilterType = EnumRaycastFilterTypeBlacklist
raycastParams.FilterDescendantsInstances = {Character, CurrentCamera}
-- // Cast ray
local Result = Raycast(Workspace, Origin, Part.Position - Origin, raycastParams)
-- // Make sure we get a result
if (Result) then
-- // Vars
local PartHit = Result.Instance
local Visible = (not PartHit or IsDescendantOf(PartHit, PartDescendant))
-- // Return
return Visible
end
end
-- // Return
return false
end
-- // Ignore player
function Aiming.IgnorePlayer(Player)
-- // Vars
local Ignored = Aiming.Ignored
local IgnoredPlayers = Ignored.Players
-- // Find player in table
for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
-- // Make sure player matches
if (IgnoredPlayer == Player) then
return false
end
end
-- // Blacklist player
tableinsert(IgnoredPlayers, Player)
return true
end
-- // Unignore Player
function Aiming.UnIgnorePlayer(Player)
-- // Vars
local Ignored = Aiming.Ignored
local IgnoredPlayers = Ignored.Players
-- // Find player in table
for i, IgnoredPlayer in ipairs(IgnoredPlayers) do
-- // Make sure player matches
if (IgnoredPlayer == Player) then
-- // Remove from ignored
tableremove(IgnoredPlayers, i)
return true
end
end
-- //
return false
end
-- // Ignore team
function Aiming.IgnoreTeam(Team, TeamColor)
-- // Vars
local Ignored = Aiming.Ignored
local IgnoredTeams = Ignored.Teams
-- // Find team in table
for _, IgnoredTeam in ipairs(IgnoredTeams) do
-- // Make sure team matches
if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
return false
end
end
-- // Ignore team
tableinsert(IgnoredTeams, {Team, TeamColor})
return true
end
-- // Unignore team
function Aiming.UnIgnoreTeam(Team, TeamColor)
-- // Vars
local Ignored = Aiming.Ignored
local IgnoredTeams = Ignored.Teams
-- // Find team in table
for i, IgnoredTeam in ipairs(IgnoredTeams) do
-- // Make sure team matches
if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
-- // Remove
tableremove(IgnoredTeams, i)
return true
end
end
-- // Return
return false
end
-- // Toggle team check
function Aiming.TeamCheck(Toggle)
if (Toggle) then
return Aiming.IgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
end
return Aiming.UnIgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
end
-- // Check teams
function Aiming.IsIgnoredTeam(Player)
-- // Vars
local Ignored = Aiming.Ignored
local IgnoredTeams = Ignored.Teams
-- // Check if team is ignored
for _, IgnoredTeam in ipairs(IgnoredTeams) do
-- // Make sure team matches
if (Player.Team == IgnoredTeam.Team and Player.TeamColor == IgnoredTeam.TeamColor) then
return true
end
end
-- // Return
return false
end
-- // Check if player (and team) is ignored
function Aiming.IsIgnored(Player)
-- // Vars
local Ignored = Aiming.Ignored
local IgnoredPlayers = Ignored.Players
-- // Loop
for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
-- // Check if Player Id
if (typeof(IgnoredPlayer) == "number" and Player.UserId == IgnoredPlayer) then
return true
end
-- // Normal Player Instance
if (IgnoredPlayer == Player) then
return true
end
end
-- // Team check
return Aiming.IsIgnoredTeam(Player)
end
-- // Get the Direction, Normal and Material
function Aiming.Raycast(Origin, Destination, UnitMultiplier)
if (typeof(Origin) == "Vector3" and typeof(Destination) == "Vector3") then
-- // Handling
if (not UnitMultiplier) then UnitMultiplier = 1 end
-- // Vars
local Direction = (Destination - Origin).Unit * UnitMultiplier
local Result = Raycast(Workspace, Origin, Direction)
-- // Make sure we have a result
if (Result) then
local Normal = Result.Normal
local Material = Result.Material
return Direction, Normal, Material
end
end
-- // Return
return nil
end
-- // Get Character
function Aiming.Character(Player)
return Player.Character
end
-- // Check Health
function Aiming.CheckHealth(Player)
-- // Get Humanoid
local Character = Aiming.Character(Player)
local Humanoid = FindFirstChildWhichIsA(Character, "Humanoid")
-- // Get Health
local Health = (Humanoid and Humanoid.Health or 0)
-- //
return Health > 0
end
-- // Check if silent aim can used
function Aiming.Check()
return (Aiming.Enabled == true and Aiming.Selected ~= LocalPlayer and Aiming.SelectedPart ~= nil)
end
Aiming.checkSilentAim = Aiming.Check
-- // Get Closest Target Part
function Aiming.GetClosestTargetPartToCursor(Character)
local TargetParts = Aiming.TargetPart
-- // Vars
local ClosestPart = nil
local ClosestPartPosition = nil
local ClosestPartOnScreen = false
local ClosestPartMagnitudeFromMouse = nil
local ShortestDistance = 1/0
-- //
local function CheckTargetPart(TargetPart)
-- // Convert string -> Instance
if (typeof(TargetPart) == "string") then
TargetPart = FindFirstChild(Character, TargetPart)
end
-- // Make sure we have a target
if not (TargetPart) then
return
end
-- // Get the length between Mouse and Target Part (on screen)
local PartPos, onScreen = WorldToViewportPoint(CurrentCamera, TargetPart.Position)
local GuiInset = GetGuiInset(GuiService)
local Magnitude = (Vector2new(PartPos.X, PartPos.Y - GuiInset.Y) - Vector2new(Mouse.X, Mouse.Y)).Magnitude
-- //
if (Magnitude < ShortestDistance) then
ClosestPart = TargetPart
ClosestPartPosition = PartPos
ClosestPartOnScreen = onScreen
ClosestPartMagnitudeFromMouse = Magnitude
ShortestDistance = Magnitude
end
end
-- // String check
if (typeof(TargetParts) == "string") then
-- // Check if it all
if (TargetParts == "All") then
-- // Loop through character children
for _, v in ipairs(Character:GetChildren()) do
-- // See if it a part
if not (v:IsA("BasePart")) then
continue
end
-- // Check it
CheckTargetPart(v)
end
else
-- // Individual
CheckTargetPart(TargetParts)
end
end
-- //
if (typeof(TargetParts) == "table") then
-- // Loop through all target parts and check them
for _, TargetPartName in ipairs(TargetParts) do
CheckTargetPart(TargetPartName)
end
end
-- //
return ClosestPart, ClosestPartPosition, ClosestPartOnScreen, ClosestPartMagnitudeFromMouse
end
-- // Silent Aim Function
function Aiming.GetClosestPlayerToCursor()
-- // Vars
local TargetPart = nil
local ClosestPlayer = nil
local Chance = CalcChance(Aiming.HitChance)
local ShortestDistance = 1/0
-- // Chance
if (not Chance) then
Aiming.Selected = LocalPlayer
Aiming.SelectedPart = nil
return LocalPlayer
end
-- // Loop through all players
for _, Player in ipairs(GetPlayers(Players)) do
-- // Get Character
local Character = Aiming.Character(Player)
-- // Make sure isn't ignored and Character exists
if (Aiming.IsIgnored(Player) == false and Character) then
-- // Vars
local TargetPartTemp, _, _, Magnitude = Aiming.GetClosestTargetPartToCursor(Character)
-- // Check if part exists and health
if (TargetPartTemp and Aiming.CheckHealth(Player)) then
-- // Check if is in FOV
if (circle.Radius > Magnitude and Magnitude < ShortestDistance) then
-- // Check if Visible
if (Aiming.VisibleCheck and not Aiming.IsPartVisible(TargetPartTemp, Character)) then continue end
-- // Set vars
ClosestPlayer = Player
ShortestDistance = Magnitude
TargetPart = TargetPartTemp
end
end
end
end
-- // End
Aiming.Selected = ClosestPlayer
Aiming.SelectedPart = TargetPart
end
-- // Heartbeat Function
Heartbeat:Connect(function()
Aiming.UpdateFOV()
Aiming.GetClosestPlayerToCursor()
end)
-- //
return Aiming