Advertisement
Sakizu

Zombie Uprising Silent Aim

Feb 24th, 2023
3,119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.29 KB | None | 0 0
  1. local zombies = game:GetService("Workspace").Zombies
  2. local Players = game:GetService("Players")
  3. local LocalPlayer = Players.LocalPlayer
  4. local mouse = LocalPlayer:GetMouse()
  5. local Camera = workspace.CurrentCamera
  6. local Debris = game:GetService("Debris")
  7. local UserInputService = game:GetService("UserInputService")
  8. local target = false
  9. local RunService = game:GetService("RunService")
  10.  
  11. getfenv().lock = "Random" -- Head or Hitbox or Random
  12.  
  13. fov = 99999
  14. local fovCircle = true
  15. local st = tonumber(tick())
  16. warn("Loading script...")
  17.  
  18. if fovCircle then
  19.     function createcircle()
  20.         local a = Drawing.new("Circle")
  21.         a.Transparency = 1
  22.         a.Thickness = 1.5
  23.         a.Visible = true
  24.         a.Color = Color3.fromRGB(0, 255, 149)
  25.         a.Filled = false
  26.         a.Radius = fov
  27.         return a
  28.     end
  29.     local fovc = createcircle()
  30.     spawn(
  31.         function()
  32.             RunService:BindToRenderStep(
  33.                 "FovCircle",
  34.                 1,
  35.                 function()
  36.                     fovc.Position = Vector2.new(mouse.X, mouse.Y)
  37.                 end
  38.             )
  39.         end
  40.     )
  41. end
  42.  
  43. -- function isFfa()
  44. -- local am = #Players:GetChildren();
  45. -- local amm = 0;
  46. -- for i , v in pairs(Players:GetChildren()) do
  47. -- if v.Team == LocalPlayer.Team then
  48. -- amm = amm + 1;
  49. -- end;
  50. -- end;
  51. -- return am == amm;
  52. --end;
  53. function getnearest()
  54.     local nearestmagnitude = math.huge
  55.     local nearestenemy = nil
  56.     local vector = nil
  57.     --local ffa = isFfa();
  58.     for i, v in next, zombies:GetChildren() do
  59.         if v and v:FindFirstChild("HumanoidRootPart") and v:FindFirstChild("Humanoid") and v.Humanoid.Health > 0 then
  60.             local vector, onScreen = Camera:WorldToScreenPoint(v["HumanoidRootPart"].Position)
  61.             if onScreen then
  62.                 local ray = Ray.new(Camera.CFrame.p, (v["Head"].Position - Camera.CFrame.p).unit * 500)
  63.                 local ignore = {
  64.                     LocalPlayer.Character
  65.                 }
  66.                 local hit, position, normal = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
  67.                 if
  68.                     hit and hit:FindFirstAncestorOfClass("Model") and
  69.                         zombies:FindFirstChild(hit:FindFirstAncestorOfClass("Model").Name)
  70.                  then
  71.                     local magnitude = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(vector.X, vector.Y)).magnitude
  72.                     if magnitude < nearestmagnitude and magnitude <= fov then
  73.                         nearestenemy = v
  74.                         nearestmagnitude = magnitude
  75.                     end
  76.                 end
  77.             end
  78.         end
  79.     end
  80.     return nearestenemy
  81. end
  82.  
  83. local meta = getrawmetatable(game)
  84. setreadonly(meta, false)
  85. local oldNamecall = meta.__namecall
  86. meta.__namecall =
  87.     newcclosure(
  88.     function(...)
  89.         local method = getnamecallmethod()
  90.         local args = {...}
  91.         if string.find(method, "Ray") then
  92.             if target then
  93.                 if args[1].Name ~= "Workspace" then
  94.                     print(args[1])
  95.                 end
  96.                 args[2] =
  97.                     Ray.new(
  98.                     workspace.CurrentCamera.CFrame.Position,
  99.                     (target.Position +
  100.                         Vector3.new(0, (workspace.CurrentCamera.CFrame.Position - target.Position).Magnitude / 500, 0) -
  101.                         workspace.CurrentCamera.CFrame.Position).unit * 5000
  102.                 )
  103.             end
  104.         end
  105.         return oldNamecall(unpack(args))
  106.     end
  107. )
  108.  
  109. warn("Script loaded!\nTime taken: " .. math.abs(tonumber(tick()) - st))
  110. RunService:BindToRenderStep(
  111.     "SilentAim",
  112.     1,
  113.     function()
  114.         if
  115.             UserInputService:IsMouseButtonPressed(0) and Players.LocalPlayer.Character and
  116.                 Players.LocalPlayer.Character:FindFirstChild("Humanoid") and
  117.                 Players.LocalPlayer.Character.Humanoid.Health > 0
  118.          then
  119.             local enemy = getnearest()
  120.             if enemy and enemy:FindFirstChild("Humanoid") and enemy.Humanoid.Health > 0 then
  121.                 local vector, onScreen = Camera:WorldToScreenPoint(enemy["Head"].Position)
  122.                 local head = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(vector.X, vector.Y)).magnitude
  123.                 local vector, onScreen = Camera:WorldToScreenPoint(enemy["HumanoidRootPart"].Position)
  124.                 local hitbox = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(vector.X, vector.Y)).magnitude
  125.                 if head <= hitbox then
  126.                     magnitude = head
  127.                 else
  128.                     magnitude = hitbox
  129.                 end
  130.                 if getfenv().lock == "Head" then
  131.                     target = workspace.Zombies[enemy.Name]["Head"]
  132.                 else
  133.                     if getfenv().lock == "Random" then
  134.                         if magnitude == hitbox then
  135.                             target = zombies[enemy.Name]["HumanoidRootPart"]
  136.                         else
  137.                             target = zombies[enemy.Name]["Head"]
  138.                         end
  139.                     else
  140.                         target = zombies[enemy.Name]["HumanoidRootPart"]
  141.                     end
  142.                 end
  143.             else
  144.                 target = nil
  145.             end
  146.         end
  147.     end
  148. )
  149.  
Tags: Roblox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement