From venuslock, 1 Week ago, written in Plain Text.
Embed
  1. --rivals new aimbot, silent aim script
  2. local replicated_storage = game.GetService(game, "ReplicatedStorage");
  3. local players = game.GetService(game, "Players");
  4.  
  5. local camera = workspace.CurrentCamera;
  6. local utility = require(replicated_storage.Modules.Utility);
  7.  
  8. local get_players = function() -- this is dumb asf, feel free to modify.
  9.     local entities = {};
  10.  
  11.     for _, child in workspace.GetChildren(workspace) do
  12.         if child.FindFirstChildOfClass(child, "Humanoid") then
  13.             table.insert(entities, child);
  14.         elseif child.Name == "HurtEffect" then
  15.             for _, hurt_player in child.GetChildren(child) do
  16.                 if (hurt_player.ClassName ~= "Highlight") then
  17.                     table.insert(entities, hurt_player);
  18.                 end
  19.             end
  20.         end
  21.     end
  22.     return entities
  23. end
  24. local get_closest_player = function()
  25.     local closest, closest_distance = nil, math.huge;
  26.     local character = players.LocalPlayer.Character;
  27.  
  28.     if (character == nil) then
  29.         return;
  30.     end
  31.  
  32.     for _, player in get_players() do
  33.         if (player == players.LocalPlayer) then
  34.             continue;
  35.         end
  36.  
  37.         if (not player:FindFirstChild("HumanoidRootPart")) then
  38.             continue;
  39.         end
  40.  
  41.         local position, on_screen = camera.WorldToViewportPoint(camera, player.HumanoidRootPart.Position);
  42.  
  43.         if (on_screen == false) then
  44.             continue;
  45.         end
  46.  
  47.         local center = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2);
  48.         local distance = (center - Vector2.new(position.X, position.Y)).Magnitude;
  49.  
  50.         if (distance > closest_distance) then
  51.             continue;
  52.         end
  53.  
  54.         closest = player;
  55.         closest_distance = distance;
  56.     end
  57.     return closest;
  58. end
  59.  
  60. local old = utility.Raycast; utility.Raycast = function(...)
  61.     local arguments = {...};
  62.  
  63.     if (#arguments > 0 and arguments[4] == 999) then
  64.         local closest = get_closest_player();
  65.  
  66.         if (closest) then
  67.             arguments[3] = closest.Head.Position;
  68.         end
  69.     end
  70.     return old(table.unpack(arguments));
  71. end