Advertisement
AALTTz

ESP

Jul 20th, 2022
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. --// Universal Box ESP (Works on Arsenal and other games)
  2.  
  3. -- settings
  4. local settings = {
  5. defaultcolor = Color3.fromRGB(255,0,0),
  6. teamcheck = false,
  7. teamcolor = true
  8. };
  9.  
  10. -- services
  11. local runService = game:GetService("RunService");
  12. local players = game:GetService("Players");
  13.  
  14. -- variables
  15. local localPlayer = players.LocalPlayer;
  16. local camera = workspace.CurrentCamera;
  17.  
  18. -- functions
  19. local newVector2, newColor3, newDrawing = Vector2.new, Color3.new, Drawing.new;
  20. local tan, rad = math.tan, math.rad;
  21. local round = function(...) local a = {}; for i,v in next, table.pack(...) do a[i] = math.round(v); end return unpack(a); end;
  22. local wtvp = function(...) local a, b = camera.WorldToViewportPoint(camera, ...) return newVector2(a.X, a.Y), b, a.Z end;
  23.  
  24. local espCache = {};
  25. local function createEsp(player)
  26. local drawings = {};
  27.  
  28. drawings.box = newDrawing("Square");
  29. drawings.box.Thickness = 1;
  30. drawings.box.Filled = false;
  31. drawings.box.Color = settings.defaultcolor;
  32. drawings.box.Visible = false;
  33. drawings.box.ZIndex = 2;
  34.  
  35. drawings.boxoutline = newDrawing("Square");
  36. drawings.boxoutline.Thickness = 3;
  37. drawings.boxoutline.Filled = false;
  38. drawings.boxoutline.Color = newColor3();
  39. drawings.boxoutline.Visible = false;
  40. drawings.boxoutline.ZIndex = 1;
  41.  
  42. espCache[player] = drawings;
  43. end
  44.  
  45. local function removeEsp(player)
  46. if rawget(espCache, player) then
  47. for _, drawing in next, espCache[player] do
  48. drawing:Remove();
  49. end
  50. espCache[player] = nil;
  51. end
  52. end
  53.  
  54. local function updateEsp(player, esp)
  55. local character = player and player.Character;
  56. if character then
  57. local cframe = character:GetModelCFrame();
  58. local position, visible, depth = wtvp(cframe.Position);
  59. esp.box.Visible = visible;
  60. esp.boxoutline.Visible = visible;
  61.  
  62. if cframe and visible then
  63. local scaleFactor = 1 / (depth * tan(rad(camera.FieldOfView / 2)) * 2) * 1000;
  64. local width, height = round(4 * scaleFactor, 5 * scaleFactor);
  65. local x, y = round(position.X, position.Y);
  66.  
  67. esp.box.Size = newVector2(width, height);
  68. esp.box.Position = newVector2(round(x - width / 2, y - height / 2));
  69. esp.box.Color = settings.teamcolor and player.TeamColor.Color or settings.defaultcolor;
  70.  
  71. esp.boxoutline.Size = esp.box.Size;
  72. esp.boxoutline.Position = esp.box.Position;
  73. end
  74. else
  75. esp.box.Visible = false;
  76. esp.boxoutline.Visible = false;
  77. end
  78. end
  79.  
  80. -- main
  81. for _, player in next, players:GetPlayers() do
  82. if player ~= localPlayer then
  83. createEsp(player);
  84. end
  85. end
  86.  
  87. players.PlayerAdded:Connect(function(player)
  88. createEsp(player);
  89. end);
  90.  
  91. players.PlayerRemoving:Connect(function(player)
  92. removeEsp(player);
  93. end)
  94.  
  95. runService:BindToRenderStep("esp", Enum.RenderPriority.Camera.Value, function()
  96. for player, drawings in next, espCache do
  97. if settings.teamcheck and player.Team == localPlayer.Team then
  98. continue;
  99. end
  100.  
  101. if drawings and player ~= localPlayer then
  102. updateEsp(player, drawings);
  103. end
  104. end
  105. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement