Advertisement
Guest User

Universal Silent Aim

a guest
Jun 6th, 2024
20,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.51 KB | None | 0 0
  1. --[[
  2. Information:
  3.  
  4. - Inspired by Averiias silent aim, Script Made by @Emmanuelz7 on YT
  5.  
  6. Credits to Douqle for UI
  7. ]]
  8.  
  9. -- // Dependencies
  10. local _, AimingPage, _ = loadstring(game:HttpGet("https://raw.githubusercontent.com/Stefanuk12/Aiming/main/GUI.lua"))()
  11. local Aiming = loadstring(game:HttpGet("https://raw.githubusercontent.com/Stefanuk12/Aiming/main/Load.lua"))()("Module")
  12. local AimingChecks = Aiming.Checks
  13. local AimingSelected = Aiming.Selected
  14. local AimingSettingsIgnored = Aiming.Settings.Ignored
  15. local AimingSettingsIgnoredPlayers = Aiming.Settings.Ignored.Players
  16. local AimingSettingsIgnoredWhitelistMode = AimingSettingsIgnored.WhitelistMode
  17.  
  18. -- // Services
  19. local UserInputService = game:GetService("UserInputService")
  20.  
  21. -- // Config
  22. local Configuration = {
  23. -- // The ones under this you may change - if you are a normal user
  24. Enabled = true,
  25. Method = "Target,Hit",
  26. FocusMode = false, -- // Stays locked on to that player only. If true then uses the silent aim keybind, if a input type is entered, then that is used
  27. ToggleBind = false, -- // true = Toggle, false = Hold (to enable)
  28. Keybind = Enum.UserInputType.MouseButton2, -- // You can also have Enum.KeyCode.E, etc.
  29.  
  30. -- // Do not change anything below here - if you are not a normal user
  31. CurrentlyFocused = nil,
  32. SupportedMethods = {
  33. __namecall = {"Raycast", "FindPartOnRay", "FindPartOnRayWithWhitelist", "FindPartOnRayWithIgnoreList"},
  34. __index = {"Target", "Hit", "X", "Y", "UnitRay"}
  35. },
  36.  
  37. ExpectedArguments = {
  38. FindPartOnRayWithIgnoreList = {
  39. ArgCountRequired = 3,
  40. Args = {
  41. "Instance", "Ray", "table", "boolean", "boolean"
  42. }
  43. },
  44. FindPartOnRayWithWhitelist = {
  45. ArgCountRequired = 3,
  46. Args = {
  47. "Instance", "Ray", "table", "boolean"
  48. }
  49. },
  50. FindPartOnRay = {
  51. ArgCountRequired = 2,
  52. Args = {
  53. "Instance", "Ray", "Instance", "boolean", "boolean"
  54. }
  55. },
  56. Raycast = {
  57. ArgCountRequired = 3,
  58. Args = {
  59. "Instance", "Vector3", "Vector3", "RaycastParams"
  60. }
  61. }
  62. }
  63. }
  64. local IsToggled = false
  65. Aiming.SilentAim = Configuration
  66.  
  67. -- // Functions
  68. local function CalculateDirection(Origin, Destination, Length)
  69. return (Destination - Origin).Unit * Length
  70. end
  71.  
  72. --// Validate arguments passed through namecall
  73. local function ValidateArguments(Args, Method)
  74. --// Get Type Information from Method
  75.  
  76. local TypeInformation = Configuration.ExpectedArguments[Method]
  77. if not TypeInformation then return false end
  78.  
  79. --// Make new table for successful matches
  80. local Matches = 0
  81.  
  82. --// Go through every argument passed
  83. for ArgumentPosition, Argument in next, Args do
  84. --// Check if argument type is a certain type
  85. if typeof(Argument) == TypeInformation.Args[ArgumentPosition] then
  86. Matches = Matches + 1
  87. end
  88. end
  89.  
  90. --// Get information
  91.  
  92. local ExpectedValid = #Args
  93. local GotValid = Matches
  94.  
  95. --// Return whether or not arguments are valid
  96. return ExpectedValid == GotValid
  97. end
  98.  
  99. -- // Additional checks you can add yourself, e.g. upvalue checks
  100. function Configuration.AdditionalCheck(metamethod, method, callingscript, ...)
  101. return true
  102. end
  103.  
  104. -- // Checks if a certain method is enabled
  105. local stringsplit = string.split
  106. local stringlower = string.lower
  107. local tablefind = table.find
  108. local function IsMethodEnabled(Method, Given, PossibleMethods)
  109. -- // Split it all up
  110. PossibleMethods = PossibleMethods or stringsplit(Configuration.Method, ",")
  111. Given = Given or Method
  112.  
  113. -- // Vars
  114. local LoweredMethod = stringlower(Method)
  115. local FoundI = tablefind(PossibleMethods, Method) or tablefind(PossibleMethods, LoweredMethod) -- // to cover stuff like target (lowercase)
  116. local Found = FoundI ~= nil
  117. local Matches = LoweredMethod == stringlower(Given)
  118.  
  119. -- // Return
  120. return Found and Matches
  121. end
  122.  
  123. -- // Allows you to easily toggle multiple methods on and off
  124. function Configuration.ToggleMethod(Method, State)
  125. -- // Vars
  126. local EnabledMethods = Configuration.Method:split(",")
  127. local FoundI = table.find(EnabledMethods, Method)
  128.  
  129. -- //
  130. if (State) then
  131. if (not FoundI) then
  132. table.insert(EnabledMethods, Method)
  133. end
  134. else
  135. if (FoundI) then
  136. table.remove(EnabledMethods, FoundI)
  137. end
  138. end
  139.  
  140. -- // Set
  141. Configuration.Method = table.concat(EnabledMethods, ",")
  142. end
  143.  
  144. -- // Modify the position/cframe, add prediction yourself (use Aiming.Selected)
  145. function Configuration.ModifyCFrame(OnScreen)
  146. return OnScreen and AimingSelected.Position or AimingSelected.Part.CFrame
  147. end
  148.  
  149. -- // Focuses a player
  150. local Backup = {table.unpack(AimingSettingsIgnoredPlayers)}
  151. function Configuration.FocusPlayer(Player)
  152. table.insert(AimingSettingsIgnoredPlayers, Player)
  153. AimingSettingsIgnoredWhitelistMode.Players = true
  154. end
  155.  
  156. -- // Unfocuses a player
  157. function Configuration.Unfocus(Player)
  158. -- // Find it within ignored, and remove if found
  159. local PlayerI = table.find(AimingSettingsIgnoredPlayers, Player)
  160. if (PlayerI) then
  161. table.remove(AimingSettingsIgnoredPlayers, PlayerI)
  162. end
  163.  
  164. -- // Disable whitelist mode
  165. AimingSettingsIgnoredWhitelistMode.Players = false
  166. end
  167.  
  168. -- // Unfocuses everything
  169. function Configuration.UnfocusAll(Replacement)
  170. Replacement = Replacement or Backup
  171. AimingSettingsIgnored.Players = Replacement
  172. AimingSettingsIgnoredWhitelistMode.Players = false
  173. end
  174.  
  175. -- //
  176. function Configuration.FocusHandler()
  177. if (Configuration.CurrentlyFocused) then
  178. Configuration.Unfocus(Configuration.CurrentlyFocused)
  179. Configuration.CurrentlyFocused = nil
  180. return
  181. end
  182.  
  183. if (AimingChecks.IsAvailable()) then
  184. Configuration.FocusPlayer(AimingSelected.Instance)
  185. Configuration.CurrentlyFocused = AimingSelected.Instance
  186. end
  187. end
  188.  
  189. -- // For the toggle and stuff
  190. local function CheckInput(Input, Expected)
  191. local InputType = Expected.EnumType == Enum.KeyCode and "KeyCode" or "UserInputType"
  192. return Input[InputType] == Expected
  193. end
  194.  
  195. UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
  196. -- // Make sure is not processed
  197. if (GameProcessedEvent) then
  198. return
  199. end
  200.  
  201. -- // Check if matches bind
  202. local FocusMode = Configuration.FocusMode
  203. if (CheckInput(Input, Configuration.Keybind)) then
  204. if (Configuration.ToggleBind) then
  205. IsToggled = not IsToggled
  206. else
  207. IsToggled = true
  208. end
  209.  
  210. if (FocusMode == true) then
  211. Configuration.FocusHandler()
  212. end
  213. end
  214.  
  215. -- // FocusMode check
  216. if (typeof(FocusMode) == "Enum" and CheckInput(Input, FocusMode)) then
  217. Configuration.FocusHandler()
  218. end
  219. end)
  220. UserInputService.InputEnded:Connect(function(Input, GameProcessedEvent)
  221. -- // Make sure is not processed
  222. if (GameProcessedEvent) then
  223. return
  224. end
  225.  
  226. -- // Check if matches bind
  227. if (CheckInput(Input, Configuration.Keybind) and not Configuration.ToggleBind) then
  228. IsToggled = false
  229. end
  230. end)
  231.  
  232. -- // Hooks
  233. local __namecall
  234. __namecall = hookmetamethod(game, "__namecall", function(...)
  235. -- // Vars
  236. local args = {...}
  237. local self = args[1]
  238. local method = getnamecallmethod()
  239. local callingscript = getcallingscript()
  240.  
  241. -- // Make sure everything is in order
  242. if (self == workspace and not checkcaller() and IsToggled and table.find(Configuration.SupportedMethods.__namecall, method) and IsMethodEnabled(method) and AimingChecks.IsAvailable() and Configuration.Enabled and ValidateArguments(args, method) and Configuration.AdditionalCheck("__namecall", method, callingscript, ...)) then
  243. -- // Raycast
  244. if (method == "Raycast") then
  245. -- // Modify args
  246. args[3] = CalculateDirection(args[2], Configuration.ModifyCFrame(false).Position, 1000)
  247.  
  248. -- // Return
  249. return __namecall(unpack(args))
  250. end
  251.  
  252. -- // The rest pretty much, modify args
  253. local Origin = args[2].Origin
  254. local Direction = CalculateDirection(Origin, AimingSelected.Part.Position, 1000)
  255. args[2] = Ray.new(Origin, Direction)
  256.  
  257. -- // Return
  258. return __namecall(unpack(args))
  259. end
  260.  
  261. -- //
  262. return __namecall(...)
  263. end)
  264.  
  265. local __index
  266. __index = hookmetamethod(game, "__index", function(t, k)
  267. -- // Vars
  268. local callingscript = getcallingscript()
  269.  
  270. -- // Make sure everything is in order
  271. if (t:IsA("Mouse") and not checkcaller() and IsToggled and AimingChecks.IsAvailable() and IsMethodEnabled(k) and Configuration.Enabled and Configuration.AdditionalCheck("__index", nil, callingscript, t, k)) then
  272. -- // Vars
  273. local LoweredK = k:lower()
  274.  
  275. -- // Target
  276. if (LoweredK == "target") then
  277. return AimingSelected.Part
  278. end
  279.  
  280. -- // Hit
  281. if (LoweredK == "hit") then
  282. return Configuration.ModifyCFrame(false)
  283. end
  284.  
  285. -- // X/Y
  286. if (LoweredK == "x" or LoweredK == "y") then
  287. return Configuration.ModifyCFrame(true)[k]
  288. end
  289.  
  290. -- // UnitRay
  291. if (LoweredK == "unitray") then
  292. local Origin = __index(t, k).Origin
  293. local Direction = CalculateDirection(Origin, Configuration.ModifyCFrame(false).Position)
  294. return Ray.new(Origin, Direction)
  295. end
  296. end
  297.  
  298. -- // Return
  299. return __index(t, k)
  300. end)
  301.  
  302. -- // GUI
  303. local SilentAimSection = AimingPage:addSection({
  304. title = "Silent Aim"
  305. })
  306.  
  307. SilentAimSection:addToggle({
  308. title = "Enabled",
  309. default = Configuration.Enabled,
  310. callback = function(value)
  311. Configuration.Enabled = value
  312. end
  313. })
  314.  
  315. SilentAimSection:addToggle({
  316. title = "Focus Mode",
  317. default = Configuration.FocusMode,
  318. callback = function(value)
  319. Configuration.FocusMode = value
  320. end
  321. })
  322.  
  323. SilentAimSection:addToggle({
  324. title = "Toggle Bind",
  325. default = Configuration.ToggleBind,
  326. callback = function(value)
  327. Configuration.ToggleBind = value
  328. end
  329. })
  330.  
  331. SilentAimSection:addKeybind({
  332. title = "Keybind",
  333. default = Configuration.Keybind,
  334. changedCallback = function(value)
  335. Configuration.Keybind = value
  336. end
  337. })
  338.  
  339. SilentAimSection:addToggle({
  340. title = "Focus Mode (Uses Keybind)",
  341. default = Configuration.FocusMode,
  342. callback = function(value)
  343. Configuration.FocusMode = value
  344. end
  345. })
  346. SilentAimSection:addKeybind({
  347. title = "Focus Mode (Custom Bind)",
  348. changedCallback = function(value)
  349. Configuration.FocusMode = value
  350. end
  351. })
  352.  
  353. -- // Adding each method
  354. local SilentAimMethodsSection = AimingPage:addSection({
  355. title = "Silent Aim: Methods"
  356. })
  357.  
  358. for _, method in ipairs(Configuration.SupportedMethods.__index) do
  359. SilentAimMethodsSection:addToggle({
  360. title = method,
  361. default = IsMethodEnabled(method),
  362. callback = function(value)
  363. Configuration.ToggleMethod(method, value)
  364. end
  365. })
  366. end
  367. for _, method in ipairs(Configuration.SupportedMethods.__namecall) do
  368. SilentAimMethodsSection:addToggle({
  369. title = method,
  370. default = IsMethodEnabled(method),
  371. callback = function(value)
  372. Configuration.ToggleMethod(method, value)
  373. end
  374. })
  375. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement