Advertisement
C-H-4-0-S

Aimhax v2

Feb 4th, 2024 (edited)
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. local FillColor = Color3.fromRGB(175,25,255)
  2. local DepthMode = "AlwaysOnTop"
  3. local FillTransparency = 0.5
  4. local OutlineColor = Color3.fromRGB(255,255,255)
  5. local OutlineTransparency = 0
  6.  
  7. local CoreGui = game:FindService("CoreGui")
  8. local Players = game:FindService("Players")
  9. local lp = Players.LocalPlayer
  10. local connections = {}
  11.  
  12. local Storage = Instance.new("Folder")
  13. Storage.Parent = CoreGui
  14. Storage.Name = "Highlight_Storage"
  15.  
  16. local function Highlight(plr)
  17. local Highlight = Instance.new("Highlight")
  18. Highlight.Name = plr.Name
  19. Highlight.FillColor = FillColor
  20. Highlight.DepthMode = DepthMode
  21. Highlight.FillTransparency = FillTransparency
  22. Highlight.OutlineColor = OutlineColor
  23. Highlight.OutlineTransparency = 0
  24. Highlight.Parent = Storage
  25.  
  26. local plrchar = plr.Character
  27. if plrchar then
  28. Highlight.Adornee = plrchar
  29. end
  30.  
  31. connections[plr] = plr.CharacterAdded:Connect(function(char)
  32. Highlight.Adornee = char
  33. end)
  34. end
  35.  
  36. Players.PlayerAdded:Connect(Highlight)
  37. for i,v in next, Players:GetPlayers() do
  38. Highlight(v)
  39. end
  40.  
  41. Players.PlayerRemoving:Connect(function(plr)
  42. local plrname = plr.Name
  43. if Storage[plrname] then
  44. Storage[plrname]:Destroy()
  45. end
  46. if connections[plr] then
  47. connections[plr]:Disconnect()
  48. end
  49. end)
  50.  
  51. -- settings
  52. local settings = {
  53. defaultcolor = Color3.fromRGB(255,0,0),
  54. teamcheck = false,
  55. teamcolor = true
  56. };
  57.  
  58. -- services
  59. local runService = game:GetService("RunService");
  60. local players = game:GetService("Players");
  61.  
  62. -- variables
  63. local localPlayer = players.LocalPlayer;
  64. local camera = workspace.CurrentCamera;
  65.  
  66. -- functions
  67. local newVector2, newColor3, newDrawing = Vector2.new, Color3.new, Drawing.new;
  68. local tan, rad = math.tan, math.rad;
  69. local round = function(...) local a = {}; for i,v in next, table.pack(...) do a[i] = math.round(v); end return unpack(a); end;
  70. local wtvp = function(...) local a, b = camera.WorldToViewportPoint(camera, ...) return newVector2(a.X, a.Y), b, a.Z end;
  71.  
  72. local espCache = {};
  73. local function createEsp(player)
  74. local drawings = {};
  75.  
  76. drawings.box = newDrawing("Square");
  77. drawings.box.Thickness = 1;
  78. drawings.box.Filled = false;
  79. drawings.box.Color = settings.defaultcolor;
  80. drawings.box.Visible = false;
  81. drawings.box.ZIndex = 2;
  82.  
  83. drawings.boxoutline = newDrawing("Square");
  84. drawings.boxoutline.Thickness = 3;
  85. drawings.boxoutline.Filled = false;
  86. drawings.boxoutline.Color = newColor3();
  87. drawings.boxoutline.Visible = false;
  88. drawings.boxoutline.ZIndex = 1;
  89.  
  90. espCache[player] = drawings;
  91. end
  92.  
  93. local function removeEsp(player)
  94. if rawget(espCache, player) then
  95. for _, drawing in next, espCache[player] do
  96. drawing:Remove();
  97. end
  98. espCache[player] = nil;
  99. end
  100. end
  101.  
  102. local function updateEsp(player, esp)
  103. local character = player and player.Character;
  104. if character then
  105. local cframe = character:GetModelCFrame();
  106. local position, visible, depth = wtvp(cframe.Position);
  107. esp.box.Visible = visible;
  108. esp.boxoutline.Visible = visible;
  109.  
  110. if cframe and visible then
  111. local scaleFactor = 1 / (depth * tan(rad(camera.FieldOfView / 2)) * 2) * 1000;
  112. local width, height = round(4 * scaleFactor, 5 * scaleFactor);
  113. local x, y = round(position.X, position.Y);
  114.  
  115. esp.box.Size = newVector2(width, height);
  116. esp.box.Position = newVector2(round(x - width / 2, y - height / 2));
  117. esp.box.Color = settings.teamcolor and player.TeamColor.Color or settings.defaultcolor;
  118.  
  119. esp.boxoutline.Size = esp.box.Size;
  120. esp.boxoutline.Position = esp.box.Position;
  121. end
  122. else
  123. esp.box.Visible = false;
  124. esp.boxoutline.Visible = false;
  125. end
  126. end
  127.  
  128. -- main
  129. for _, player in next, players:GetPlayers() do
  130. if player ~= localPlayer then
  131. createEsp(player);
  132. end
  133. end
  134.  
  135. players.PlayerAdded:Connect(function(player)
  136. createEsp(player);
  137. end);
  138.  
  139. players.PlayerRemoving:Connect(function(player)
  140. removeEsp(player);
  141. end)
  142.  
  143. runService:BindToRenderStep("esp", Enum.RenderPriority.Camera.Value, function()
  144. for player, drawings in next, espCache do
  145. if settings.teamcheck and player.Team == localPlayer.Team then
  146. continue;
  147. end
  148.  
  149. if drawings and player ~= localPlayer then
  150. updateEsp(player, drawings);
  151. end
  152. end
  153. end)
  154.  
  155. -- Custom Crosshair by zzerexx#3970
  156. getgenv().CrosshairSettings = {
  157. Color = Color3.fromRGB(255,0,0),
  158. RainbowColor = true,
  159. Opacity = 9,
  160. Length = 10,-- Length of each line
  161. Thickness = 2,-- Thickness of each line
  162. Offset = 4, -- Offset from the middle point
  163. Dot = true, -- not recommended
  164. FollowCursor = false, -- Crosshair follows the cursor
  165. HideMouseIcon = true, -- Hides the mouse icon, set to 0 to ignore
  166. HideGameCrosshair = true, -- Hides the current game's crosshair (if its supported)
  167. ToggleKey = Enum.KeyCode.RightAlt, -- Toggles crosshair visibility
  168. } -- v1.2.1
  169. loadstring(game:HttpGet("https://raw.githubusercontent.com/zzerexx/scripts/main/CustomCrosshair.lua", true))()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement