Advertisement
Okb00mer

Untitled

Dec 14th, 2022 (edited)
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.91 KB | None | 0 0
  1. if getgenv().Aiming then return getgenv().Aiming end
  2.  
  3. -- // Services
  4. local Players = game:GetService("Players")
  5. local Workspace = game:GetService("Workspace")
  6. local GuiService = game:GetService("GuiService")
  7. local RunService = game:GetService("RunService")
  8.  
  9. -- // Vars
  10. local Heartbeat = RunService.Heartbeat
  11. local LocalPlayer = Players.LocalPlayer
  12. local CurrentCamera = Workspace.CurrentCamera
  13. local Mouse = LocalPlayer:GetMouse()
  14.  
  15. -- // Optimisation Vars (ugly)
  16. local Drawingnew = Drawing.new
  17. local Color3fromRGB = Color3.fromRGB
  18. local Vector2new = Vector2.new
  19. local GetGuiInset = GuiService.GetGuiInset
  20. local Randomnew = Random.new
  21. local mathfloor = math.floor
  22. local CharacterAdded = LocalPlayer.CharacterAdded
  23. local CharacterAddedWait = CharacterAdded.Wait
  24. local WorldToViewportPoint = CurrentCamera.WorldToViewportPoint
  25. local RaycastParamsnew = RaycastParams.new
  26. local EnumRaycastFilterTypeBlacklist = Enum.RaycastFilterType.Blacklist
  27. local Raycast = Workspace.Raycast
  28. local GetPlayers = Players.GetPlayers
  29. local Instancenew = Instance.new
  30. local IsDescendantOf = Instancenew("Part").IsDescendantOf
  31. local FindFirstChildWhichIsA = Instancenew("Part").FindFirstChildWhichIsA
  32. local FindFirstChild = Instancenew("Part").FindFirstChild
  33. local tableremove = table.remove
  34. local tableinsert = table.insert
  35.  
  36. -- // Silent Aim Vars
  37. getgenv().Aiming = {
  38. Enabled = true,
  39.  
  40. ShowFOV = false,
  41. FOV = 50,
  42. FOVSides = 300,
  43. FOVColour = Color3fromRGB(98, 37, 209),
  44.  
  45. VisibleCheck = true,
  46.  
  47. HitChance = 110,
  48.  
  49. Resolver = true,
  50.  
  51. Selected = nil,
  52. SelectedPart = nil,
  53.  
  54. TargetPart = {"Head", "HumanoidRootPart", "LowerTorso"},
  55.  
  56. Ignored = {
  57. Teams = {
  58. {
  59. Team = LocalPlayer.Team,
  60. TeamColor = LocalPlayer.TeamColor,
  61. },
  62. },
  63. Players = {
  64. LocalPlayer,
  65. 91318356
  66. }
  67. }
  68. }
  69. local Aiming = getgenv().Aiming
  70.  
  71. -- // Create circle
  72. local circle = Drawingnew("Circle")
  73. circle.Transparency = 1
  74. circle.Thickness = 2
  75. circle.Color = Aiming.FOVColour
  76. circle.Filled = false
  77. Aiming.FOVCircle = circle
  78.  
  79. -- // Update
  80. function Aiming.UpdateFOV()
  81. -- // Make sure the circle exists
  82. if not (circle) then
  83. return
  84. end
  85.  
  86. -- // Set Circle Properties
  87. circle.Visible = Aiming.ShowFOV
  88. circle.Radius = (Aiming.FOV * 3)
  89. circle.Position = Vector2new(Mouse.X, Mouse.Y + GetGuiInset(GuiService).Y)
  90. circle.NumSides = Aiming.FOVSides
  91. circle.Color = Aiming.FOVColour
  92.  
  93. -- // Return circle
  94. return circle
  95. end
  96.  
  97. -- // Custom Functions
  98. local CalcChance = function(percentage)
  99. -- // Floor the percentage
  100. percentage = mathfloor(percentage)
  101.  
  102. -- // Get the chance
  103. local chance = mathfloor(Randomnew().NextNumber(Randomnew(), 0, 1) * 100) / 100
  104.  
  105. -- // Return
  106. return chance <= percentage / 100
  107. end
  108.  
  109. -- // Customisable Checking Functions: Is a part visible
  110. function Aiming.IsPartVisible(Part, PartDescendant)
  111. -- // Vars
  112. local Character = LocalPlayer.Character or CharacterAddedWait(CharacterAdded)
  113. local Origin = CurrentCamera.CFrame.Position
  114. local _, OnScreen = WorldToViewportPoint(CurrentCamera, Part.Position)
  115.  
  116. -- //
  117. if (OnScreen) then
  118. -- // Vars
  119. local raycastParams = RaycastParamsnew()
  120. raycastParams.FilterType = EnumRaycastFilterTypeBlacklist
  121. raycastParams.FilterDescendantsInstances = {Character, CurrentCamera}
  122.  
  123. -- // Cast ray
  124. local Result = Raycast(Workspace, Origin, Part.Position - Origin, raycastParams)
  125.  
  126. -- // Make sure we get a result
  127. if (Result) then
  128. -- // Vars
  129. local PartHit = Result.Instance
  130. local Visible = (not PartHit or IsDescendantOf(PartHit, PartDescendant))
  131.  
  132. -- // Return
  133. return Visible
  134. end
  135. end
  136.  
  137. -- // Return
  138. return false
  139. end
  140.  
  141. -- // Ignore player
  142. function Aiming.IgnorePlayer(Player)
  143. -- // Vars
  144. local Ignored = Aiming.Ignored
  145. local IgnoredPlayers = Ignored.Players
  146.  
  147. -- // Find player in table
  148. for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
  149. -- // Make sure player matches
  150. if (IgnoredPlayer == Player) then
  151. return false
  152. end
  153. end
  154.  
  155. -- // Blacklist player
  156. tableinsert(IgnoredPlayers, Player)
  157. return true
  158. end
  159.  
  160. -- // Unignore Player
  161. function Aiming.UnIgnorePlayer(Player)
  162. -- // Vars
  163. local Ignored = Aiming.Ignored
  164. local IgnoredPlayers = Ignored.Players
  165.  
  166. -- // Find player in table
  167. for i, IgnoredPlayer in ipairs(IgnoredPlayers) do
  168. -- // Make sure player matches
  169. if (IgnoredPlayer == Player) then
  170. -- // Remove from ignored
  171. tableremove(IgnoredPlayers, i)
  172. return true
  173. end
  174. end
  175.  
  176. -- //
  177. return false
  178. end
  179.  
  180. -- // Ignore team
  181. function Aiming.IgnoreTeam(Team, TeamColor)
  182. -- // Vars
  183. local Ignored = Aiming.Ignored
  184. local IgnoredTeams = Ignored.Teams
  185.  
  186. -- // Find team in table
  187. for _, IgnoredTeam in ipairs(IgnoredTeams) do
  188. -- // Make sure team matches
  189. if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
  190. return false
  191. end
  192. end
  193.  
  194. -- // Ignore team
  195. tableinsert(IgnoredTeams, {Team, TeamColor})
  196. return true
  197. end
  198.  
  199. -- // Unignore team
  200. function Aiming.UnIgnoreTeam(Team, TeamColor)
  201. -- // Vars
  202. local Ignored = Aiming.Ignored
  203. local IgnoredTeams = Ignored.Teams
  204.  
  205. -- // Find team in table
  206. for i, IgnoredTeam in ipairs(IgnoredTeams) do
  207. -- // Make sure team matches
  208. if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
  209. -- // Remove
  210. tableremove(IgnoredTeams, i)
  211. return true
  212. end
  213. end
  214.  
  215. -- // Return
  216. return false
  217. end
  218.  
  219. -- // Toggle team check
  220. function Aiming.TeamCheck(Toggle)
  221. if (Toggle) then
  222. return Aiming.IgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
  223. end
  224.  
  225. return Aiming.UnIgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
  226. end
  227.  
  228. -- // Check teams
  229. function Aiming.IsIgnoredTeam(Player)
  230. -- // Vars
  231. local Ignored = Aiming.Ignored
  232. local IgnoredTeams = Ignored.Teams
  233.  
  234. -- // Check if team is ignored
  235. for _, IgnoredTeam in ipairs(IgnoredTeams) do
  236. -- // Make sure team matches
  237. if (Player.Team == IgnoredTeam.Team and Player.TeamColor == IgnoredTeam.TeamColor) then
  238. return true
  239. end
  240. end
  241.  
  242. -- // Return
  243. return false
  244. end
  245.  
  246. -- // Check if player (and team) is ignored
  247. function Aiming.IsIgnored(Player)
  248. -- // Vars
  249. local Ignored = Aiming.Ignored
  250. local IgnoredPlayers = Ignored.Players
  251.  
  252. -- // Loop
  253. for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
  254. -- // Check if Player Id
  255. if (typeof(IgnoredPlayer) == "number" and Player.UserId == IgnoredPlayer) then
  256. return true
  257. end
  258.  
  259. -- // Normal Player Instance
  260. if (IgnoredPlayer == Player) then
  261. return true
  262. end
  263. end
  264.  
  265. -- // Team check
  266. return Aiming.IsIgnoredTeam(Player)
  267. end
  268.  
  269. -- // Get the Direction, Normal and Material
  270. function Aiming.Raycast(Origin, Destination, UnitMultiplier)
  271. if (typeof(Origin) == "Vector3" and typeof(Destination) == "Vector3") then
  272. -- // Handling
  273. if (not UnitMultiplier) then UnitMultiplier = 1 end
  274.  
  275. -- // Vars
  276. local Direction = (Destination - Origin).Unit * UnitMultiplier
  277. local Result = Raycast(Workspace, Origin, Direction)
  278.  
  279. -- // Make sure we have a result
  280. if (Result) then
  281. local Normal = Result.Normal
  282. local Material = Result.Material
  283.  
  284. return Direction, Normal, Material
  285. end
  286. end
  287.  
  288. -- // Return
  289. return nil
  290. end
  291.  
  292. -- // Get Character
  293. function Aiming.Character(Player)
  294. return Player.Character
  295. end
  296.  
  297. -- // Check Health
  298. function Aiming.CheckHealth(Player)
  299. -- // Get Humanoid
  300. local Character = Aiming.Character(Player)
  301. local Humanoid = FindFirstChildWhichIsA(Character, "Humanoid")
  302.  
  303. -- // Get Health
  304. local Health = (Humanoid and Humanoid.Health or 0)
  305.  
  306. -- //
  307. return Health > 0
  308. end
  309.  
  310. -- // Check if silent aim can used
  311. function Aiming.Check()
  312. return (Aiming.Enabled == true and Aiming.Selected ~= LocalPlayer and Aiming.SelectedPart ~= nil)
  313. end
  314. Aiming.checkSilentAim = Aiming.Check
  315.  
  316. -- // Get Closest Target Part
  317. function Aiming.GetClosestTargetPartToCursor(Character)
  318. local TargetParts = Aiming.TargetPart
  319.  
  320. -- // Vars
  321. local ClosestPart = nil
  322. local ClosestPartPosition = nil
  323. local ClosestPartOnScreen = false
  324. local ClosestPartMagnitudeFromMouse = nil
  325. local ShortestDistance = 1/0
  326.  
  327. -- //
  328. local function CheckTargetPart(TargetPart)
  329. -- // Convert string -> Instance
  330. if (typeof(TargetPart) == "string") then
  331. TargetPart = FindFirstChild(Character, TargetPart)
  332. end
  333.  
  334. -- // Make sure we have a target
  335. if not (TargetPart) then
  336. return
  337. end
  338.  
  339. -- // Get the length between Mouse and Target Part (on screen)
  340. local PartPos, onScreen = WorldToViewportPoint(CurrentCamera, TargetPart.Position)
  341. local GuiInset = GetGuiInset(GuiService)
  342. local Magnitude = (Vector2new(PartPos.X, PartPos.Y - GuiInset.Y) - Vector2new(Mouse.X, Mouse.Y)).Magnitude
  343.  
  344. -- //
  345. if (Magnitude < ShortestDistance) then
  346. ClosestPart = TargetPart
  347. ClosestPartPosition = PartPos
  348. ClosestPartOnScreen = onScreen
  349. ClosestPartMagnitudeFromMouse = Magnitude
  350. ShortestDistance = Magnitude
  351. end
  352. end
  353.  
  354. -- // String check
  355. if (typeof(TargetParts) == "string") then
  356. -- // Check if it all
  357. if (TargetParts == "All") then
  358. -- // Loop through character children
  359. for _, v in ipairs(Character:GetChildren()) do
  360. -- // See if it a part
  361. if not (v:IsA("BasePart")) then
  362. continue
  363. end
  364.  
  365. -- // Check it
  366. CheckTargetPart(v)
  367. end
  368. else
  369. -- // Individual
  370. CheckTargetPart(TargetParts)
  371. end
  372. end
  373.  
  374. -- //
  375. if (typeof(TargetParts) == "table") then
  376. -- // Loop through all target parts and check them
  377. for _, TargetPartName in ipairs(TargetParts) do
  378. CheckTargetPart(TargetPartName)
  379. end
  380. end
  381.  
  382. -- //
  383. return ClosestPart, ClosestPartPosition, ClosestPartOnScreen, ClosestPartMagnitudeFromMouse
  384. end
  385.  
  386. -- // Silent Aim Function
  387. function Aiming.GetClosestPlayerToCursor()
  388. -- // Vars
  389. local TargetPart = nil
  390. local ClosestPlayer = nil
  391. local Chance = CalcChance(Aiming.HitChance)
  392. local ShortestDistance = 1/0
  393.  
  394. -- // Chance
  395. if (not Chance) then
  396. Aiming.Selected = LocalPlayer
  397. Aiming.SelectedPart = nil
  398.  
  399. return LocalPlayer
  400. end
  401.  
  402. -- // Loop through all players
  403. for _, Player in ipairs(GetPlayers(Players)) do
  404. -- // Get Character
  405. local Character = Aiming.Character(Player)
  406.  
  407. -- // Make sure isn't ignored and Character exists
  408. if (Aiming.IsIgnored(Player) == false and Character) then
  409. -- // Vars
  410. local TargetPartTemp, _, _, Magnitude = Aiming.GetClosestTargetPartToCursor(Character)
  411.  
  412. -- // Check if part exists and health
  413. if (TargetPartTemp and Aiming.CheckHealth(Player)) then
  414. -- // Check if is in FOV
  415. if (circle.Radius > Magnitude and Magnitude < ShortestDistance) then
  416. -- // Check if Visible
  417. if (Aiming.VisibleCheck and not Aiming.IsPartVisible(TargetPartTemp, Character)) then continue end
  418.  
  419. -- // Set vars
  420. ClosestPlayer = Player
  421. ShortestDistance = Magnitude
  422. TargetPart = TargetPartTemp
  423. end
  424. end
  425. end
  426. end
  427.  
  428. -- // End
  429. Aiming.Selected = ClosestPlayer
  430. Aiming.SelectedPart = TargetPart
  431. end
  432.  
  433. -- // Heartbeat Function
  434. Heartbeat:Connect(function()
  435. Aiming.UpdateFOV()
  436. Aiming.GetClosestPlayerToCursor()
  437. end)
  438.  
  439. if getgenv().Aiming.Resolver == true then
  440. local RunService = game:GetService("RunService")
  441.  
  442. RunService.Heartbeat:Connect(function()
  443. pcall(function()
  444. for i,v in pairs(game.Players:GetChildren()) do
  445. if v.Name ~= game.Players.LocalPlayer.Name then
  446. local hrp = v.Character.HumanoidRootPart
  447. hrp.Velocity = Vector3.new(hrp.Velocity.X, 0, hrp.Velocity.Z)
  448. hrp.AssemblyLinearVelocity = Vector3.new(hrp.Velocity.X, 0, hrp.Velocity.Z)
  449. end
  450. end
  451. end)
  452. end)
  453. end
  454.  
  455. -- //
  456. return Aimingd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement