darraghd493

Darragh's (old) ESP: Adjusted for Models

Sep 29th, 2024 (edited)
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.39 KB | None | 0 0
  1. -- Do not copy, modify, or redistribute without permission
  2. -- Made by darraghd493
  3.  
  4. local Players = game:GetService("Players")
  5. local RunService = game:GetService("RunService")
  6. local Workspace = game:GetService("Workspace")
  7. local CoreGui = game:GetService("CoreGui")
  8.  
  9. -- Constants
  10. local LocalPlayer = Players.LocalPlayer
  11. local Camera = Workspace.CurrentCamera
  12. local Mouse = LocalPlayer:GetMouse()
  13.  
  14. -- Variables
  15. local library = {
  16.     options = {
  17.         enabled = true,
  18.  
  19.         box = false,
  20.         boxProjected = false,
  21.         boxOutline = true,
  22.         boxBackground = false,
  23.         boxColour = Color3.fromRGB(255, 255, 255),
  24.         boxBackgroundColour = Color3.fromRGB(0, 0, 0),
  25.         boxBackgroundTransparency = 0.2,
  26.     },
  27.     objects = {},
  28.     tables = {
  29.         offsets = {
  30.             head = Vector3.new(0, 0.5, 0),
  31.             torso = Vector3.new(0, 1.5, 0),
  32.             leg = Vector3.new(0, 3, 0)
  33.         }
  34.     },
  35.     hooks = {},
  36.     utils = {}
  37. }
  38.  
  39. -- Lua functions
  40. local function exists(object, index)
  41.     local error, value = pcall(function()
  42.         return object[index]
  43.     end)
  44.     return value
  45. end
  46.  
  47. -- Drawing functions
  48. local function setVisible(drawing, state)
  49.     if exists(drawing, "Visible") then
  50.         drawing.Visible = state
  51.         return
  52.     end
  53.  
  54.     for i,v in pairs(drawing) do
  55.         if exists(v, "Visible") then
  56.             v.Visible = state
  57.         end
  58.     end
  59. end
  60.  
  61. local function recursiveRemove(object, index)
  62.     index = index or 0
  63.     if index > 5 then return end
  64.  
  65.     for i,v in pairs(object) do
  66.        
  67.         if exists(v, "Visible") then
  68.             v:Remove()
  69.         else
  70.             recursiveRemove(object, index + 1)
  71.         end
  72.     end
  73. end
  74.  
  75. local function recursiveRemove(object, index, max)
  76.     index = index or 0
  77.     max = max or 5
  78.     if index > max then return end
  79.  
  80.     for i,v in pairs(object) do
  81.        
  82.         if exists(v, "Visible") then
  83.             v:Remove()
  84.         else
  85.             recursiveRemove(object, index + 1, max)
  86.         end
  87.     end
  88. end
  89.  
  90. -- Player functions
  91. local function canDraw(player)
  92.     return player ~= nil and player:FindFirstChild("Humanoid") ~= nil and player:FindFirstChild("HumanoidRootPart") ~= nil and player:FindFirstChild("Head") ~= nil and player.Humanoid.Health > 0
  93. end
  94.  
  95. -- ESP functions
  96. local function boxESP(player)
  97.     library.objects[player].box = {}
  98.  
  99.     local box = library.objects[player].box
  100.     box.projected = {}
  101.     box.outline = Drawing.new("Square")
  102.     box.outline.Visible = false
  103.     box.outline.Color = Color3.fromRGB(0, 0, 0)
  104.     box.outline.Thickness = 3
  105.     box.outline.Transparency = 1
  106.     box.outline.Filled = false
  107.  
  108.     box.background = Drawing.new("Square")
  109.     box.background.Visible = false
  110.     box.background.Color = Color3.fromRGB(0, 0, 0)
  111.     box.background.Thickness = 1
  112.     box.background.Transparency = 0.2
  113.     box.background.Filled = true
  114.  
  115.     box.main = Drawing.new("Square")
  116.     box.main.Visible = false
  117.     box.main.Color = Color3.fromRGB(255, 255, 255)
  118.     box.main.Thickness = 1
  119.     box.main.Transparency = 1
  120.     box.main.Filled = false
  121.  
  122.     box.projected.outline = Drawing.new("Quad")
  123.     box.projected.outline.Visible = false
  124.     box.projected.outline.Color = Color3.fromRGB(0, 0, 0)
  125.     box.projected.outline.Thickness = 6
  126.     box.projected.outline.Transparency = 1
  127.     box.projected.outline.Filled = false
  128.  
  129.     box.projected.background = Drawing.new("Quad")
  130.     box.projected.background.Visible = false
  131.     box.projected.background.Color = Color3.fromRGB(0, 0, 0)
  132.     box.projected.background.Thickness = 3
  133.     box.projected.background.Transparency = 0.2
  134.     box.projected.background.Filled = true
  135.  
  136.     box.projected.main = Drawing.new("Quad")
  137.     box.projected.main.Visible = false
  138.     box.projected.main.Color = Color3.fromRGB(255, 255, 255)
  139.     box.projected.main.Thickness = 3
  140.     box.projected.main.Transparency = 1
  141.     box.projected.main.Filled = false
  142.  
  143.     local function update()
  144.         if not library.options.enabled or library.options.box == false or not canDraw(player) then
  145.             setVisible(box.projected, false)
  146.             setVisible(box, false)
  147.             return
  148.         end
  149.  
  150.         local pos, onScreen = Camera:WorldToViewportPoint(player.HumanoidRootPart.Position)
  151.         if not onScreen then
  152.             setVisible(box.projected, false)
  153.             setVisible(box, false)
  154.             return
  155.         end
  156.  
  157.         if library.options.boxProjected then
  158.             setVisible(box, false)
  159.  
  160.             local cframe = player.HumanoidRootPart.CFrame + Vector3.new(0, player.HumanoidRootPart.Size.Y / 2, 0)
  161.             local size = Vector3.new(4, 6, 0)
  162.             local shift = CFrame.new(0, -1.5, 0)
  163.             local locations = {
  164.                 topLeft = cframe * shift * CFrame.new(size.X / 2, size.Y / 2, 0),
  165.                 topRight = cframe * shift * CFrame.new(-size.X / 2, size.Y / 2, 0),
  166.                 bottomLeft = cframe * shift * CFrame.new(size.X / 2, -size.Y / 2, 0),
  167.                 bottomRight = cframe * shift * CFrame.new(-size.X / 2, -size.Y / 2, 0),
  168.                 torso = cframe * shift
  169.             }
  170.  
  171.             local topLeftPos, topLeftOnScreen = Camera:WorldToViewportPoint(locations.topLeft.Position)
  172.             local topRightPos, topRightOnScreen = Camera:WorldToViewportPoint(locations.topRight.Position)
  173.             local bottomLeftPos, bottomLeftOnScreen = Camera:WorldToViewportPoint(locations.bottomLeft.Position)
  174.             local bottomRightPos, bottomRightOnScreen = Camera:WorldToViewportPoint(locations.bottomRight.Position)
  175.  
  176.             if not topLeftPos and not topRightPos and not bottomLeftPos and not bottomRightPos then
  177.                 setVisible(box.projected, false)
  178.                 return
  179.             end
  180.  
  181.             if library.options.boxOutline then
  182.                 box.projected.outline.PointA = Vector2.new(topLeftPos.X, topLeftPos.Y)
  183.                 box.projected.outline.PointB = Vector2.new(topRightPos.X, topRightPos.Y)
  184.                 box.projected.outline.PointC = Vector2.new(bottomRightPos.X, bottomRightPos.Y)
  185.                 box.projected.outline.PointD = Vector2.new(bottomLeftPos.X, bottomLeftPos.Y)
  186.                 box.projected.outline.Visible = true
  187.             else
  188.                 box.projected.outline.Visible = false
  189.             end
  190.  
  191.             if library.options.boxBackground then
  192.                 box.projected.background.PointA = Vector2.new(topLeftPos.X, topLeftPos.Y)
  193.                 box.projected.background.PointB = Vector2.new(topRightPos.X, topRightPos.Y)
  194.                 box.projected.background.PointC = Vector2.new(bottomRightPos.X, bottomRightPos.Y)
  195.                 box.projected.background.PointD = Vector2.new(bottomLeftPos.X, bottomLeftPos.Y)
  196.                 box.projected.background.Color = library.options.boxColour
  197.                 box.projected.background.Transparency = library.options.boxBackgroundTransparency
  198.                 box.projected.background.Visible = true
  199.             else
  200.                 box.projected.background.Visible = false
  201.             end
  202.  
  203.             box.projected.main.PointA = Vector2.new(topLeftPos.X, topLeftPos.Y)
  204.             box.projected.main.PointB = Vector2.new(topRightPos.X, topRightPos.Y)
  205.             box.projected.main.PointC = Vector2.new(bottomRightPos.X, bottomRightPos.Y)
  206.             box.projected.main.PointD = Vector2.new(bottomLeftPos.X, bottomLeftPos.Y)
  207.             box.projected.main.Color = library.options.boxColour
  208.             box.projected.main.Visible = true
  209.         else
  210.             setVisible(box.projected, false)
  211.  
  212.             local rootPart = player.HumanoidRootPart
  213.             local head = player.Head
  214.  
  215.             local headPos, headOnScreen = Camera:WorldToViewportPoint(head.Position + library.tables.offsets.head)
  216.             local rootPos, rootOnScreen = Camera:WorldToViewportPoint(rootPart.Position + library.tables.offsets.torso)
  217.             local legPos, legOnScreen = Camera:WorldToViewportPoint(rootPart.Position - library.tables.offsets.leg)
  218.  
  219.             local cameraPosition = Camera.CFrame.Position
  220.             local distance = (rootPart.Position - cameraPosition).Magnitude
  221.             local scale = Camera.ViewportSize.X - distance
  222.  
  223.             local boxSize = Vector2.new(scale / rootPos.Z, headPos.Y - legPos.Y)
  224.             local boxPos = Vector2.new(rootPos.X - boxSize.X / 2, rootPos.Y - boxSize.Y)
  225.  
  226.             if library.options.boxOutline then
  227.                 box.outline.Size = boxSize
  228.                 box.outline.Position = boxPos
  229.                 box.outline.Visible = true
  230.             else
  231.                 box.outline.Visible = false
  232.             end
  233.            
  234.             if library.options.boxBackground then
  235.                 box.background.Size = boxSize
  236.                 box.background.Position = boxPos
  237.                 box.background.Color = library.options.boxColour
  238.                 box.background.Transparency = library.options.boxBackgroundTransparency
  239.                 box.background.Visible = true
  240.             else
  241.                 box.background.Visible = false
  242.             end
  243.  
  244.             box.main.Size = boxSize
  245.             box.main.Position = boxPos
  246.             box.main.Color = library.options.boxColour
  247.             box.main.Visible = true
  248.         end
  249.     end
  250.  
  251.     table.insert(library.hooks, RunService.RenderStepped:Connect(function()
  252.         update()
  253.     end))
  254. end
  255.  
  256.  
  257. local function loadESP(player)
  258.     library.objects[player] = {}
  259.     boxESP(player)
  260. end
  261.  
  262. -- Library
  263. function library:ESP(player)
  264.     loadESP(player)
  265. end
  266.  
  267. function library:Stop()
  268.     for i,v in pairs(library.hooks) do
  269.         v:Disconnect()
  270.     end
  271.  
  272.     for i,v in pairs(library.objects) do
  273.         recursiveRemove(v, 10)
  274.     end
  275. end
  276.  
  277. return library
Tags: old
Advertisement
Add Comment
Please, Sign In to add comment