Advertisement
YellowGreg

Silent Aim | KAT

Aug 13th, 2023 (edited)
3,348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. --// Modify by YellowGreg
  2.  
  3. -- Services
  4. local Plrs = game:GetService("Players")
  5. local RnSr = game:GetService("RunService")
  6.  
  7. -- Player
  8. local P = Plrs.LocalPlayer
  9. local M = P:GetMouse()
  10. local Cam = workspace.CurrentCamera
  11.  
  12. -- Settings
  13. local S = {
  14.     fov = 150,      -- Field of view angle for target selection
  15.     hitbox = "Head",-- Hitbox to aim at (e.g., "Head", "Torso")
  16.     fovcircle = true,-- Show FOV circle
  17. }
  18.  
  19. -- UI Elements
  20. local CircleInline = Drawing.new("Circle")
  21. local CircleOutline = Drawing.new("Circle")
  22. CircleInline.Visible = S.fovcircle
  23. CircleOutline.Visible = S.fovcircle
  24. CircleOutline.Thickness = 4
  25. CircleInline.Thickness = 2
  26. CircleOutline.Color = Color3.new()
  27. CircleInline.Color = Color3.fromRGB(255, 255, 255)
  28. CircleOutline.ZIndex = 1
  29. CircleInline.ZIndex = 2
  30.  
  31. -- Find closest target within FOV
  32. local function GetClosest(Fov)
  33.     local T, C = nil, Fov or math.huge
  34.  
  35.     for _, v in pairs(Plrs:GetPlayers()) do
  36.         if v ~= P and v.Character and v.Character:FindFirstChild(S.hitbox) then
  37.             local Pos, OnScr = Cam:WorldToScreenPoint(v.Character[S.hitbox].Position)
  38.             local Dist = (Vector2.new(Pos.X, Pos.Y) - Vector2.new(M.X, M.Y)).Magnitude
  39.  
  40.             if Dist < C and OnScr then
  41.                 C = Dist
  42.                 T = v
  43.             end
  44.         end
  45.     end
  46.  
  47.     return T
  48. end
  49.  
  50. -- Current target
  51. local Tgt
  52.  
  53. -- Update UI and target
  54. RnSr.Stepped:Connect(function()
  55.     CircleInline.Radius = S.fov
  56.     CircleInline.Position = Vector2.new(M.X, M.Y + 36)
  57.    
  58.     CircleOutline.Radius = S.fov
  59.     CircleOutline.Position = Vector2.new(M.X, M.Y + 36)
  60.    
  61.     Tgt = GetClosest(S.fov)
  62. end)
  63.  
  64. -- Modify FindPartOnRayWithIgnoreList function
  65. local Old
  66. Old = hookmetamethod(game, "__namecall", function(Self, ...)
  67.     local Args = {...}
  68.  
  69.     if not checkcaller() and getnamecallmethod() == "FindPartOnRayWithIgnoreList" then
  70.         if table.find(Args[2], workspace.WorldIgnore.Ignore) and Tgt and Tgt.Character then
  71.             local Origin = Args[1].Origin
  72.             Args[1] = Ray.new(Origin, Tgt.Character[S.hitbox].Position - Origin)
  73.         end
  74.     end
  75.  
  76.     return Old(Self, unpack(Args))
  77. end)
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement