Advertisement
Okb00mer

Untitled

Feb 26th, 2023
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.42 KB | None | 0 0
  1. if getgenv().Cfg then return getgenv().Cfg 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. local UserInputService = game:GetService("UserInputService")
  9.  
  10. -- // Vars
  11. local Heartbeat = RunService.Heartbeat
  12. local LocalPlayer = Players.LocalPlayer
  13. local CurrentCamera = Workspace.CurrentCamera
  14. local Mouse = LocalPlayer:GetMouse()
  15.  
  16. -- // Optimisation Vars (ugly)
  17. local Drawingnew = Drawing.new
  18. local Color3fromRGB = Color3.fromRGB
  19. local Vector2new = Vector2.new
  20. local GetGuiInset = GuiService.GetGuiInset
  21. local Randomnew = Random.new
  22. local mathfloor = math.floor
  23. local CharacterAdded = LocalPlayer.CharacterAdded
  24. local CharacterAddedWait = CharacterAdded.Wait
  25. local WorldToViewportPoint = CurrentCamera.WorldToViewportPoint
  26. local RaycastParamsnew = RaycastParams.new
  27. local EnumRaycastFilterTypeBlacklist = Enum.RaycastFilterType.Blacklist
  28. local Raycast = Workspace.Raycast
  29. local GetPlayers = Players.GetPlayers
  30. local Instancenew = Instance.new
  31. local IsDescendantOf = Instancenew("Part").IsDescendantOf
  32. local FindFirstChildWhichIsA = Instancenew("Part").FindFirstChildWhichIsA
  33. local FindFirstChild = Instancenew("Part").FindFirstChild
  34. local tableremove = table.remove
  35. local tableinsert = table.insert
  36. local RenderStepped = RunService.RenderStepped
  37. local RenderSteppedWait = RenderStepped.Wait
  38. local GetMouseLocation = UserInputService.GetMouseLocation
  39.  
  40. -- // Silent Aim Vars
  41. local Aiming = {
  42. Enabled = false,
  43. transpar = 0.3,
  44. kids = false,
  45. ShowFOV = true,
  46. FOV = 23.5,
  47. FOVSides = 100,
  48. FOVColour = Color3fromRGB(0, 153, 153),
  49.  
  50. VisibleCheck = true,
  51.  
  52. HitChance = 100,
  53.  
  54. Selected = nil,
  55. SelectedPart = nil,
  56. SelectedPosition = nil,
  57. SelectedPositionOnScreen = nil,
  58.  
  59. TargetPart = {"Head", "UpperTorso", "HumanoidRootPart", "LeftHand", "RightHand", "LeftFoot", "RightFoot"},
  60.  
  61. Ignored = {
  62. Teams = {
  63. {
  64. Team = LocalPlayer.Team,
  65. TeamColor = LocalPlayer.TeamColor,
  66. },
  67. },
  68. Players = {
  69. LocalPlayer,
  70. 91318356
  71. }
  72. },
  73.  
  74. RaycastIgnore = nil,
  75. }
  76. getgenv().Cfg = Aiming
  77.  
  78. -- // Create circle
  79. local circle = Drawingnew("Circle")
  80. circle.Transparency = Aiming.transpar
  81. circle.Thickness = 2
  82. circle.Color = Aiming.FOVColour
  83. circle.Filled = Aiming.kids
  84. Aiming.FOVCircle = circle
  85.  
  86. -- // Update
  87. function Aiming.UpdateFOV()
  88. -- // Make sure the circle exists
  89. if not (circle) then
  90. return
  91. end
  92.  
  93. -- // Set Circle Properties
  94. circle.Visible = Settings.Visible
  95. circle.Radius = (Settings.FOV * 3)
  96. circle.Position = Vector2new(Mouse.X, Mouse.Y + GetGuiInset(GuiService).Y)
  97. circle.NumSides = Aiming.FOVSides
  98. circle.Color = Aiming.FOVColour
  99. circle.Filled = Aiming.kids
  100.  
  101.  
  102. -- // Return circle
  103. return circle
  104. end
  105.  
  106. -- // Custom Functions
  107. local CalcChance = function(percentage)
  108. -- // Floor the percentage
  109. percentage = mathfloor(percentage)
  110.  
  111. -- // Get the chance
  112. local chance = mathfloor(Randomnew().NextNumber(Randomnew(), 0, 1) * 100) / 100
  113.  
  114. -- // Return
  115. return chance <= percentage / 100
  116. end
  117.  
  118. -- // Customisable Checking Functions: Is a part visible
  119. function Aiming.IsPartVisible(Part, PartDescendant)
  120. -- // Vars
  121. local Character = LocalPlayer.Character or CharacterAddedWait(CharacterAdded)
  122. local Origin = CurrentCamera.CFrame.Position
  123. local _, OnScreen = WorldToViewportPoint(CurrentCamera, Part.Position)
  124.  
  125. -- //
  126. if (OnScreen) then
  127. -- // Vars
  128. local raycastParams = RaycastParamsnew()
  129. raycastParams.FilterType = EnumRaycastFilterTypeBlacklist
  130. raycastParams.FilterDescendantsInstances = Aiming.RaycastIgnore or {Character, CurrentCamera}
  131.  
  132. -- // Cast ray
  133. local Result = Raycast(Workspace, Origin, Part.Position - Origin, raycastParams)
  134.  
  135. -- // Make sure we get a result
  136. if (Result) then
  137. -- // Vars
  138. local PartHit = Result.Instance
  139. local Visible = (not PartHit or IsDescendantOf(PartHit, PartDescendant))
  140.  
  141. -- // Return
  142. return Visible
  143. end
  144. end
  145.  
  146. -- // Return
  147. return false
  148. end
  149.  
  150. -- // Ignore player
  151. function Aiming.IgnorePlayer(Player)
  152. -- // Vars
  153. local Ignored = Aiming.Ignored
  154. local IgnoredPlayers = Ignored.Players
  155.  
  156. -- // Find player in table
  157. for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
  158. -- // Make sure player matches
  159. if (IgnoredPlayer == Player) then
  160. return false
  161. end
  162. end
  163.  
  164. -- // Blacklist player
  165. tableinsert(IgnoredPlayers, Player)
  166. return true
  167. end
  168.  
  169. -- // Unignore Player
  170. function Aiming.UnIgnorePlayer(Player)
  171. -- // Vars
  172. local Ignored = Aiming.Ignored
  173. local IgnoredPlayers = Ignored.Players
  174.  
  175. -- // Find player in table
  176. for i, IgnoredPlayer in ipairs(IgnoredPlayers) do
  177. -- // Make sure player matches
  178. if (IgnoredPlayer == Player) then
  179. -- // Remove from ignored
  180. tableremove(IgnoredPlayers, i)
  181. return true
  182. end
  183. end
  184.  
  185. -- //
  186. return false
  187. end
  188.  
  189. -- // Ignore team
  190. function Aiming.IgnoreTeam(Team, TeamColor)
  191. -- // Vars
  192. local Ignored = Aiming.Ignored
  193. local IgnoredTeams = Ignored.Teams
  194.  
  195. -- // Find team in table
  196. for _, IgnoredTeam in ipairs(IgnoredTeams) do
  197. -- // Make sure team matches
  198. if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
  199. return false
  200. end
  201. end
  202.  
  203. -- // Ignore team
  204. tableinsert(IgnoredTeams, {Team, TeamColor})
  205. return true
  206. end
  207.  
  208. -- // Unignore team
  209. function Aiming.UnIgnoreTeam(Team, TeamColor)
  210. -- // Vars
  211. local Ignored = Aiming.Ignored
  212. local IgnoredTeams = Ignored.Teams
  213.  
  214. -- // Find team in table
  215. for i, IgnoredTeam in ipairs(IgnoredTeams) do
  216. -- // Make sure team matches
  217. if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
  218. -- // Remove
  219. tableremove(IgnoredTeams, i)
  220. return true
  221. end
  222. end
  223.  
  224. -- // Return
  225. return false
  226. end
  227.  
  228. -- // Toggle team check
  229. function Aiming.TeamCheck(Toggle)
  230. if (Toggle) then
  231. return Aiming.IgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
  232. end
  233.  
  234. return Aiming.UnIgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
  235. end
  236.  
  237. -- // Check teams
  238. function Aiming.IsIgnoredTeam(Player)
  239. -- // Vars
  240. local Ignored = Aiming.Ignored
  241. local IgnoredTeams = Ignored.Teams
  242.  
  243. -- // Check if team is ignored
  244. for _, IgnoredTeam in ipairs(IgnoredTeams) do
  245. -- // Make sure team matches
  246. if (Player.Team == IgnoredTeam.Team and Player.TeamColor == IgnoredTeam.TeamColor) then
  247. return true
  248. end
  249. end
  250.  
  251. -- // Return
  252. return false
  253. end
  254.  
  255. -- // Check if player (and team) is ignored
  256. function Aiming.IsIgnored(Player)
  257. -- // Vars
  258. local Ignored = Aiming.Ignored
  259. local IgnoredPlayers = Ignored.Players
  260.  
  261. -- // Loop
  262. for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
  263. -- // Check if Player Id
  264. if (typeof(IgnoredPlayer) == "number" and Player.UserId == IgnoredPlayer) then
  265. return true
  266. end
  267.  
  268. -- // Normal Player Instance
  269. if (IgnoredPlayer == Player) then
  270. return true
  271. end
  272. end
  273.  
  274. -- // Team check
  275. return Aiming.IsIgnoredTeam(Player)
  276. end
  277.  
  278. -- // Get the Direction, Normal and Material
  279. function Aiming.Raycast(Origin, Destination, UnitMultiplier)
  280. if (typeof(Origin) == "Vector3" and typeof(Destination) == "Vector3") then
  281. -- // Handling
  282. if (not UnitMultiplier) then UnitMultiplier = 1 end
  283.  
  284. -- // Vars
  285. local Direction = (Destination - Origin).Unit * UnitMultiplier
  286. local Result = Raycast(Workspace, Origin, Direction)
  287.  
  288. -- // Make sure we have a result
  289. if (Result) then
  290. local Normal = Result.Normal
  291. local Material = Result.Material
  292.  
  293. return Direction, Normal, Material
  294. end
  295. end
  296.  
  297. -- // Return
  298. return nil
  299. end
  300.  
  301. -- // Get Character
  302. function Aiming.Character(Player)
  303. return Player.Character
  304. end
  305.  
  306. -- // Check Health
  307. function Aiming.CheckHealth(Player)
  308. -- // Get Humanoid
  309. local Character = Aiming.Character(Player)
  310. local Humanoid = FindFirstChildWhichIsA(Character, "Humanoid")
  311.  
  312. -- // Get Health
  313. local Health = (Humanoid and Humanoid.Health or 0)
  314.  
  315. -- //
  316. return Health > 0
  317. end
  318.  
  319. -- // Custom Check Function
  320. function Aiming.CheckCustom(Player)
  321. return true
  322. end
  323.  
  324. -- // Check if silent aim can used
  325. function Aiming.Check()
  326. return (Aiming.Enabled == true and Aiming.Selected ~= LocalPlayer and Aiming.SelectedPart ~= nil)
  327. end
  328. Aiming.checkSilentAim = Aiming.Check
  329.  
  330. -- // Get Closest Target Part
  331. function Aiming.GetClosestTargetPartToCursor(Character)
  332. local TargetParts = Aiming.TargetPart
  333.  
  334. -- // Vars
  335. local ClosestPart = nil
  336. local ClosestPartPosition = nil
  337. local ClosestPartOnScreen = false
  338. local ClosestPartMagnitudeFromMouse = nil
  339. local ShortestDistance = 1/0
  340.  
  341. -- //
  342. local function CheckTargetPart(TargetPart)
  343. -- // Convert string -> Instance
  344. if (typeof(TargetPart) == "string") then
  345. TargetPart = FindFirstChild(Character, TargetPart)
  346. end
  347.  
  348. -- // Make sure we have a target
  349. if not (TargetPart) then
  350. return
  351. end
  352.  
  353. -- // Get the length between Mouse and Target Part (on screen)
  354. local PartPos, onScreen = WorldToViewportPoint(CurrentCamera, TargetPart.Position)
  355. local GuiInset = GetGuiInset(GuiService)
  356. local Magnitude = (Vector2new(PartPos.X, PartPos.Y - GuiInset.Y) - Vector2new(Mouse.X, Mouse.Y)).Magnitude
  357.  
  358. -- //
  359. if (Magnitude < ShortestDistance) then
  360. ClosestPart = TargetPart
  361. ClosestPartPosition = PartPos
  362. ClosestPartOnScreen = onScreen
  363. ClosestPartMagnitudeFromMouse = Magnitude
  364. ShortestDistance = Magnitude
  365. end
  366. end
  367.  
  368. -- // String check
  369. if (typeof(TargetParts) == "string") then
  370. -- // Check if it all
  371. if (TargetParts == "All") then
  372. -- // Loop through character children
  373. for _, v in ipairs(Character:GetChildren()) do
  374. -- // See if it a part
  375. if not (v:IsA("BasePart")) then
  376. continue
  377. end
  378.  
  379. -- // Check it
  380. CheckTargetPart(v)
  381. end
  382. else
  383. -- // Individual
  384. CheckTargetPart(TargetParts)
  385. end
  386. end
  387.  
  388. -- //
  389. if (typeof(TargetParts) == "table") then
  390. -- // Loop through all target parts and check them
  391. for _, TargetPartName in ipairs(TargetParts) do
  392. CheckTargetPart(TargetPartName)
  393. end
  394. end
  395.  
  396. -- //
  397. return ClosestPart, ClosestPartPosition, ClosestPartOnScreen, ClosestPartMagnitudeFromMouse
  398. end
  399.  
  400. -- // Silent Aim Function
  401. function Aiming.GetClosestPlayerToCursor()
  402. -- // Vars
  403. local TargetPart = nil
  404. local ClosestPlayer = nil
  405. local PartPosition = nil
  406. local PartPositionOnScreen = nil
  407. local Chance = CalcChance(Aiming.HitChance)
  408. local ShortestDistance = 1/0
  409.  
  410. -- // Chance
  411. if (not Chance) then
  412. Aiming.Selected = LocalPlayer
  413. Aiming.SelectedPart = nil
  414. Aiming.SelectedPosition = nil
  415. Aiming.SelectedPositionOnScreen = nil
  416.  
  417. return LocalPlayer
  418. end
  419.  
  420. -- // Loop through all players
  421. for _, Player in ipairs(GetPlayers(Players)) do
  422. -- // Get Character
  423. local Character = Aiming.Character(Player)
  424.  
  425. -- // Make sure isn't ignored and Character exists
  426. if (Aiming.IsIgnored(Player) == false and Character) then
  427. -- // Vars
  428. local TargetPartTemp, PartPositionTemp, PartPositionOnScreenTemp, Magnitude = Aiming.GetClosestTargetPartToCursor(Character)
  429.  
  430. -- // Check if part exists, health and custom
  431. if (TargetPartTemp and Aiming.CheckHealth(Player) and Aiming.CheckCustom(Player)) then
  432. -- // Check if is in FOV
  433. if (circle.Radius > Magnitude and Magnitude < ShortestDistance) then
  434. -- // Check if Visible
  435. if (Aiming.VisibleCheck and not Aiming.IsPartVisible(TargetPartTemp, Character)) then continue end
  436.  
  437. -- // Set vars
  438. ClosestPlayer = Player
  439. ShortestDistance = Magnitude
  440. TargetPart = TargetPartTemp
  441. PartPosition = PartPositionTemp
  442. PartPositionOnScreen = PartPositionOnScreenTemp
  443. end
  444. end
  445. end
  446. end
  447.  
  448. -- // End
  449. Aiming.Selected = ClosestPlayer
  450. Aiming.SelectedPart = TargetPart
  451. Aiming.SelectedPosition = PartPosition
  452. Aiming.SelectedPositionOnScreen = PartPositionOnScreen
  453. end
  454.  
  455. -- // Beizer Aim Curves
  456. Aiming.BeizerCurve = {}
  457. do
  458. -- // Vars
  459. local AimingBeizerCurve = Aiming.BeizerCurve
  460.  
  461. -- // Functions
  462. function Aiming.BeizerCurve.Cubic(t, StartPoint, EndPoint, ControlPointA, ControlPointB)
  463. local t1 = (1 - t)
  464.  
  465. local A = t1^3 * StartPoint
  466. local B = 3 * t1^2 * t * ControlPointA
  467. local C = 3 * t1 * t^2 * ControlPointB
  468. local D = t^3 * EndPoint
  469.  
  470. return A + B + C + D
  471. end
  472. local function DoControlPoint(StartPoint, EndPoint, ControlPointA, ControlPointB)
  473. -- //
  474. local Change = (EndPoint - StartPoint)
  475.  
  476. -- // Calculate the control points - relative to the start and end points
  477. local A = StartPoint + (Change * ControlPointA)
  478. local B = StartPoint + (Change * ControlPointB)
  479.  
  480. -- //
  481. return A, B
  482. end
  483.  
  484. -- // Vars
  485. local t = 0
  486. local tThreshold = 0.99995
  487. local StartPoint = Vector2new()
  488. local EndPoint = Vector2new()
  489. local CurvePoints = {
  490. Vector2.new(0.83, 0),
  491. Vector2.new(0.17, 1)
  492. }
  493. local IsActive = false
  494. local Smoothness = 0.0025
  495. local DrawPath = false
  496.  
  497. -- // AimTo with Beizer Curves
  498. function Aiming.BeizerCurve.AimTo(Data)
  499. -- // Vars
  500. local MousePosition = GetMouseLocation(UserInputService)
  501. StartPoint = MousePosition
  502. EndPoint = Data.TargetPosition
  503. Smoothness = Data.Smoothness or Smoothness
  504. CurvePoints = Data.CurvePoints or CurvePoints
  505. DrawPath = Data.DrawPath or DrawPath
  506.  
  507. -- // Set Active
  508. t = 0
  509. IsActive = true
  510. end
  511.  
  512. -- //
  513. RunService:BindToRenderStep("AimLockBeizer", 0, function()
  514. -- // Make sure is active
  515. if (not IsActive) then
  516. return
  517. end
  518.  
  519. -- // Vars
  520. local BeizerCurve = AimingBeizerCurve.Cubic
  521.  
  522. -- // I have to do it this way because a for loop stops before hand
  523. while (t <= 1 and IsActive) do RenderSteppedWait(RenderStepped)
  524. -- // Increment
  525. t = t + Smoothness
  526.  
  527. -- // If past threshold, then do regular smoothing
  528. if (t >= tThreshold) then
  529. -- // Regular smoothing
  530. local clampedT = math.clamp(t, 0, 1)
  531. local New = StartPoint:Lerp(EndPoint, clampedT)
  532.  
  533. -- // Move mouse
  534. mousemoveabs(New.X, New.Y)
  535. else
  536. -- // Work out X, Y based upon the curve
  537. local A, B = DoControlPoint(StartPoint, EndPoint, unpack(CurvePoints))
  538. local Position = BeizerCurve(t, StartPoint, EndPoint, A, B)
  539.  
  540. -- // Create Circle [Debugging]
  541. if (DrawPath) then
  542. local Path = Drawingnew("Circle")
  543. Path.Radius = 2
  544. Path.Color = Color3fromRGB(255, 150, 150)
  545. Path.Visible = true
  546. Path.Position = Position
  547. task.delay(1, function()
  548. Path:Remove()
  549. end)
  550.  
  551. local ControlPointA = Drawingnew("Circle")
  552. ControlPointA.Radius = 5
  553. ControlPointA.Color = Color3fromRGB(225, 150, 255)
  554. ControlPointA.Visible = true
  555. ControlPointA.Position = A
  556. task.delay(1, function()
  557. ControlPointA:Remove()
  558. end)
  559.  
  560. local ControlPointB = Drawingnew("Circle")
  561. ControlPointB.Radius = 5
  562. ControlPointB.Color = Color3fromRGB(225, 150, 255)
  563. ControlPointB.Visible = true
  564. ControlPointB.Position = B
  565. task.delay(1, function()
  566. ControlPointB:Remove()
  567. end)
  568. end
  569.  
  570. -- // Move mouse
  571. mousemoveabs(Position.X, Position.Y)
  572. end
  573. end
  574.  
  575. -- // Reset
  576. IsActive = false
  577. end)
  578. end
  579.  
  580. -- // Heartbeat Function
  581. Heartbeat:Connect(function()
  582. Aiming.UpdateFOV()
  583. Aiming.GetClosestPlayerToCursor()
  584. end)
  585.  
  586. -- //
  587. return Aiming
  588.  
  589. -- // If you want the examples, look at the docs.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement