Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Do not copy, modify, or redistribute without permission
- -- Made by darraghd493
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local Workspace = game:GetService("Workspace")
- local CoreGui = game:GetService("CoreGui")
- -- Constants
- local LocalPlayer = Players.LocalPlayer
- local Camera = Workspace.CurrentCamera
- local Mouse = LocalPlayer:GetMouse()
- -- Variables
- local library = {
- options = {
- enabled = true,
- box = false,
- boxProjected = false,
- boxOutline = true,
- boxBackground = false,
- boxColour = Color3.fromRGB(255, 255, 255),
- boxBackgroundColour = Color3.fromRGB(0, 0, 0),
- boxBackgroundTransparency = 0.2,
- },
- objects = {},
- tables = {
- offsets = {
- head = Vector3.new(0, 0.5, 0),
- torso = Vector3.new(0, 1.5, 0),
- leg = Vector3.new(0, 3, 0)
- }
- },
- hooks = {},
- utils = {}
- }
- -- Lua functions
- local function exists(object, index)
- local error, value = pcall(function()
- return object[index]
- end)
- return value
- end
- -- Drawing functions
- local function setVisible(drawing, state)
- if exists(drawing, "Visible") then
- drawing.Visible = state
- return
- end
- for i,v in pairs(drawing) do
- if exists(v, "Visible") then
- v.Visible = state
- end
- end
- end
- local function recursiveRemove(object, index)
- index = index or 0
- if index > 5 then return end
- for i,v in pairs(object) do
- if exists(v, "Visible") then
- v:Remove()
- else
- recursiveRemove(object, index + 1)
- end
- end
- end
- local function recursiveRemove(object, index, max)
- index = index or 0
- max = max or 5
- if index > max then return end
- for i,v in pairs(object) do
- if exists(v, "Visible") then
- v:Remove()
- else
- recursiveRemove(object, index + 1, max)
- end
- end
- end
- -- Player functions
- local function canDraw(player)
- return player ~= nil and player:FindFirstChild("Humanoid") ~= nil and player:FindFirstChild("HumanoidRootPart") ~= nil and player:FindFirstChild("Head") ~= nil and player.Humanoid.Health > 0
- end
- -- ESP functions
- local function boxESP(player)
- library.objects[player].box = {}
- local box = library.objects[player].box
- box.projected = {}
- box.outline = Drawing.new("Square")
- box.outline.Visible = false
- box.outline.Color = Color3.fromRGB(0, 0, 0)
- box.outline.Thickness = 3
- box.outline.Transparency = 1
- box.outline.Filled = false
- box.background = Drawing.new("Square")
- box.background.Visible = false
- box.background.Color = Color3.fromRGB(0, 0, 0)
- box.background.Thickness = 1
- box.background.Transparency = 0.2
- box.background.Filled = true
- box.main = Drawing.new("Square")
- box.main.Visible = false
- box.main.Color = Color3.fromRGB(255, 255, 255)
- box.main.Thickness = 1
- box.main.Transparency = 1
- box.main.Filled = false
- box.projected.outline = Drawing.new("Quad")
- box.projected.outline.Visible = false
- box.projected.outline.Color = Color3.fromRGB(0, 0, 0)
- box.projected.outline.Thickness = 6
- box.projected.outline.Transparency = 1
- box.projected.outline.Filled = false
- box.projected.background = Drawing.new("Quad")
- box.projected.background.Visible = false
- box.projected.background.Color = Color3.fromRGB(0, 0, 0)
- box.projected.background.Thickness = 3
- box.projected.background.Transparency = 0.2
- box.projected.background.Filled = true
- box.projected.main = Drawing.new("Quad")
- box.projected.main.Visible = false
- box.projected.main.Color = Color3.fromRGB(255, 255, 255)
- box.projected.main.Thickness = 3
- box.projected.main.Transparency = 1
- box.projected.main.Filled = false
- local function update()
- if not library.options.enabled or library.options.box == false or not canDraw(player) then
- setVisible(box.projected, false)
- setVisible(box, false)
- return
- end
- local pos, onScreen = Camera:WorldToViewportPoint(player.HumanoidRootPart.Position)
- if not onScreen then
- setVisible(box.projected, false)
- setVisible(box, false)
- return
- end
- if library.options.boxProjected then
- setVisible(box, false)
- local cframe = player.HumanoidRootPart.CFrame + Vector3.new(0, player.HumanoidRootPart.Size.Y / 2, 0)
- local size = Vector3.new(4, 6, 0)
- local shift = CFrame.new(0, -1.5, 0)
- local locations = {
- topLeft = cframe * shift * CFrame.new(size.X / 2, size.Y / 2, 0),
- topRight = cframe * shift * CFrame.new(-size.X / 2, size.Y / 2, 0),
- bottomLeft = cframe * shift * CFrame.new(size.X / 2, -size.Y / 2, 0),
- bottomRight = cframe * shift * CFrame.new(-size.X / 2, -size.Y / 2, 0),
- torso = cframe * shift
- }
- local topLeftPos, topLeftOnScreen = Camera:WorldToViewportPoint(locations.topLeft.Position)
- local topRightPos, topRightOnScreen = Camera:WorldToViewportPoint(locations.topRight.Position)
- local bottomLeftPos, bottomLeftOnScreen = Camera:WorldToViewportPoint(locations.bottomLeft.Position)
- local bottomRightPos, bottomRightOnScreen = Camera:WorldToViewportPoint(locations.bottomRight.Position)
- if not topLeftPos and not topRightPos and not bottomLeftPos and not bottomRightPos then
- setVisible(box.projected, false)
- return
- end
- if library.options.boxOutline then
- box.projected.outline.PointA = Vector2.new(topLeftPos.X, topLeftPos.Y)
- box.projected.outline.PointB = Vector2.new(topRightPos.X, topRightPos.Y)
- box.projected.outline.PointC = Vector2.new(bottomRightPos.X, bottomRightPos.Y)
- box.projected.outline.PointD = Vector2.new(bottomLeftPos.X, bottomLeftPos.Y)
- box.projected.outline.Visible = true
- else
- box.projected.outline.Visible = false
- end
- if library.options.boxBackground then
- box.projected.background.PointA = Vector2.new(topLeftPos.X, topLeftPos.Y)
- box.projected.background.PointB = Vector2.new(topRightPos.X, topRightPos.Y)
- box.projected.background.PointC = Vector2.new(bottomRightPos.X, bottomRightPos.Y)
- box.projected.background.PointD = Vector2.new(bottomLeftPos.X, bottomLeftPos.Y)
- box.projected.background.Color = library.options.boxColour
- box.projected.background.Transparency = library.options.boxBackgroundTransparency
- box.projected.background.Visible = true
- else
- box.projected.background.Visible = false
- end
- box.projected.main.PointA = Vector2.new(topLeftPos.X, topLeftPos.Y)
- box.projected.main.PointB = Vector2.new(topRightPos.X, topRightPos.Y)
- box.projected.main.PointC = Vector2.new(bottomRightPos.X, bottomRightPos.Y)
- box.projected.main.PointD = Vector2.new(bottomLeftPos.X, bottomLeftPos.Y)
- box.projected.main.Color = library.options.boxColour
- box.projected.main.Visible = true
- else
- setVisible(box.projected, false)
- local rootPart = player.HumanoidRootPart
- local head = player.Head
- local headPos, headOnScreen = Camera:WorldToViewportPoint(head.Position + library.tables.offsets.head)
- local rootPos, rootOnScreen = Camera:WorldToViewportPoint(rootPart.Position + library.tables.offsets.torso)
- local legPos, legOnScreen = Camera:WorldToViewportPoint(rootPart.Position - library.tables.offsets.leg)
- local cameraPosition = Camera.CFrame.Position
- local distance = (rootPart.Position - cameraPosition).Magnitude
- local scale = Camera.ViewportSize.X - distance
- local boxSize = Vector2.new(scale / rootPos.Z, headPos.Y - legPos.Y)
- local boxPos = Vector2.new(rootPos.X - boxSize.X / 2, rootPos.Y - boxSize.Y)
- if library.options.boxOutline then
- box.outline.Size = boxSize
- box.outline.Position = boxPos
- box.outline.Visible = true
- else
- box.outline.Visible = false
- end
- if library.options.boxBackground then
- box.background.Size = boxSize
- box.background.Position = boxPos
- box.background.Color = library.options.boxColour
- box.background.Transparency = library.options.boxBackgroundTransparency
- box.background.Visible = true
- else
- box.background.Visible = false
- end
- box.main.Size = boxSize
- box.main.Position = boxPos
- box.main.Color = library.options.boxColour
- box.main.Visible = true
- end
- end
- table.insert(library.hooks, RunService.RenderStepped:Connect(function()
- update()
- end))
- end
- local function loadESP(player)
- library.objects[player] = {}
- boxESP(player)
- end
- -- Library
- function library:ESP(player)
- loadESP(player)
- end
- function library:Stop()
- for i,v in pairs(library.hooks) do
- v:Disconnect()
- end
- for i,v in pairs(library.objects) do
- recursiveRemove(v, 10)
- end
- end
- return library
Advertisement
Add Comment
Please, Sign In to add comment