Advertisement
UBinsaid1

Untitled

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