Advertisement
Zynee

esp

Jan 25th, 2025 (edited)
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.02 KB | None | 0 0
  1. -- only work with codex i haven't tested on other executor
  2.  
  3. local Noti = loadstring(game:HttpGet("https://raw.githubusercontent.com/Jxereas/UI-Libraries/main/notification_gui_library.lua", true))()
  4.  
  5. Noti.new("success", "Welcome To Celvyn!", "Thank you for using our script.", true, 5)
  6.  
  7. local settings = {
  8.     defaultcolor = Color3.fromRGB(255, 255, 255),
  9.     teamcheck = false,
  10.     teamcolor = true,
  11.     espEnabled = true
  12. }
  13.  
  14. local runService = game:GetService("RunService")
  15. local players = game:GetService("Players")
  16. local localPlayer = players.LocalPlayer
  17. local camera = workspace.CurrentCamera
  18. local userInputService = game:GetService("UserInputService")
  19.  
  20. local newVector2, newColor3, newDrawing = Vector2.new, Color3.new, Drawing.new
  21. local tan, rad = math.tan, math.rad
  22. local round = function(...)
  23.     local a = {}
  24.     for i, v in next, table.pack(...) do
  25.         a[i] = math.round(v)
  26.     end
  27.     return unpack(a)
  28. end
  29.  
  30. local wtvp = function(...)
  31.     local a, b = camera.WorldToViewportPoint(camera, ...)
  32.     return newVector2(a.X, a.Y), b, a.Z
  33. end
  34.  
  35. local function getRoot(part)
  36.     return part:IsA("Model") and part.PrimaryPart or part:FindFirstChildWhichIsA("BasePart") or part
  37. end
  38.  
  39. local espCache = {}
  40. local function createEsp(player)
  41.     local drawings = {}
  42.     drawings.box = newDrawing("Square")
  43.     drawings.box.Thickness = 1.5
  44.     drawings.box.Filled = false
  45.     drawings.box.Color = settings.defaultcolor
  46.     drawings.box.Visible = false
  47.  
  48.     drawings.healthbar = newDrawing("Square")
  49.     drawings.healthbar.Thickness = 1
  50.     drawings.healthbar.Filled = true
  51.     drawings.healthbar.Color = Color3.new(0, 1, 0)
  52.     drawings.healthbar.Visible = false
  53.  
  54.     drawings.distance = newDrawing("Text")
  55.     drawings.distance.Size = 16
  56.     drawings.distance.Center = true
  57.     drawings.distance.Color = Color3.new(1, 1, 1)
  58.     drawings.distance.Visible = false
  59.     drawings.distance.Font = 3
  60.  
  61.     drawings.username = newDrawing("Text")
  62.     drawings.username.Size = 16
  63.     drawings.username.Center = true
  64.     drawings.username.Color = Color3.new(1, 1, 1)
  65.     drawings.username.Visible = false
  66.     drawings.username.Font = 3
  67.  
  68.     drawings.healthPercent = newDrawing("Text")
  69.     drawings.healthPercent.Size = 16
  70.     drawings.healthPercent.Center = true
  71.     drawings.healthPercent.Color = Color3.new(1, 1, 1)
  72.     drawings.healthPercent.Visible = false
  73.     drawings.healthPercent.Font = 3
  74.  
  75.     espCache[player] = drawings
  76. end
  77.  
  78. local function removeEsp(player)
  79.     if rawget(espCache, player) then
  80.         for _, drawing in next, espCache[player] do
  81.             drawing.Visible = false
  82.             drawing:Remove()
  83.         end
  84.         espCache[player] = nil
  85.     end
  86. end
  87.  
  88. local function updateEsp(player, esp)
  89.     local character = player and player.Character
  90.     if character and settings.espEnabled then
  91.         local humanoid = character:FindFirstChildOfClass("Humanoid")
  92.         local rootPart = character:FindFirstChild("HumanoidRootPart")
  93.         if rootPart and humanoid and humanoid.Health > 0 then
  94.             local cframe = rootPart.CFrame
  95.             local position, visible, depth = wtvp(cframe.Position)
  96.             esp.box.Visible = visible
  97.             esp.healthbar.Visible = visible
  98.             esp.distance.Visible = visible
  99.             esp.username.Visible = visible
  100.             esp.healthPercent.Visible = visible
  101.  
  102.             if visible then
  103.                 local scaleFactor = 1 / (depth * tan(rad(camera.FieldOfView / 2)) * 2) * 1000
  104.                 local width, height = round(3 * scaleFactor, 5 * scaleFactor)
  105.                 local x, y = round(position.X, position.Y)
  106.  
  107.                 esp.box.Size = newVector2(width, height)
  108.                 esp.box.Position = newVector2(round(x - width / 2, y - height / 2))
  109.                 esp.box.Color = settings.teamcolor and player.TeamColor.Color or settings.defaultcolor
  110.  
  111.                 local roundedHealth = math.floor(humanoid.Health + 0.5)
  112.                 local healthPercent = roundedHealth / humanoid.MaxHealth
  113.  
  114.                 esp.healthbar.Size = newVector2(2, height * healthPercent)
  115.                 esp.healthbar.Position = newVector2(esp.box.Position.X - 6, esp.box.Position.Y + (height * (1 - healthPercent)))
  116.  
  117.                 local pos = math.floor((getRoot(players.LocalPlayer.Character).Position - getRoot(player.Character).Position).magnitude)
  118.                 esp.distance.Text = string.format("%d M", pos)
  119.                 esp.distance.Position = esp.box.Position + newVector2(width / 2, height + 2)
  120.  
  121.                 esp.username.Text = player.DisplayName .. " | " .. player.Name
  122.                 esp.username.Position = esp.box.Position + newVector2(width / 2, -20)
  123.  
  124.                 esp.healthPercent.Text = string.format("%.0f%%", healthPercent * 100)
  125.                 esp.healthPercent.Position = esp.healthbar.Position - newVector2(24, 0)
  126.             end
  127.         else
  128.             esp.box.Visible = false
  129.             esp.healthbar.Visible = false
  130.             esp.distance.Visible = false
  131.             esp.username.Visible = false
  132.             esp.healthPercent.Visible = false
  133.         end
  134.     else
  135.         esp.box.Visible = false
  136.         esp.healthbar.Visible = false
  137.         esp.distance.Visible = false
  138.         esp.username.Visible = false
  139.         esp.healthPercent.Visible = false
  140.     end
  141. end
  142.  
  143. for _, player in next, players:GetPlayers() do
  144.     if player ~= localPlayer then
  145.         createEsp(player)
  146.     end
  147. end
  148.  
  149. players.PlayerAdded:Connect(function(player)
  150.     createEsp(player)
  151. end)
  152.  
  153. players.PlayerRemoving:Connect(function(player)
  154.     removeEsp(player)
  155. end)
  156.  
  157. runService:BindToRenderStep("esp", Enum.RenderPriority.Camera.Value, function()
  158.     if settings.espEnabled then
  159.         for player, drawings in next, espCache do
  160.             if not (settings.teamcheck and player.Team == localPlayer.Team) then
  161.                 if drawings and player ~= localPlayer then
  162.                     updateEsp(player, drawings)
  163.                 end
  164.             end
  165.         end
  166.     else
  167.         for _, drawings in pairs(espCache) do
  168.             for _, drawing in pairs(drawings) do
  169.                 drawing.Visible = false
  170.             end
  171.         end
  172.     end
  173. end)
  174.  
  175. local ScreenGui = Instance.new("ScreenGui")
  176. ScreenGui.Parent = game.CoreGui
  177.  
  178. local ToggleButton = Instance.new("TextButton", ScreenGui)
  179. ToggleButton.Size = UDim2.new(0, 100, 0, 100)
  180. ToggleButton.Position = UDim2.new(0.85, 0, 0.05, 0)
  181. ToggleButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  182. ToggleButton.Text = "ESP ON"
  183. ToggleButton.TextScaled = true
  184. ToggleButton.Font = 28
  185. ToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  186. ToggleButton.BorderSizePixel = 0
  187. ToggleButton.BackgroundTransparency = 0.5
  188. ToggleButton.ZIndex = 10
  189. ToggleButton.Draggable = true
  190.  
  191. local isDragging = false
  192. local dragInput, mousePos, framePos
  193.  
  194. ToggleButton.InputBegan:Connect(function(input)
  195.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  196.         isDragging = true
  197.         mousePos = input.Position
  198.         framePos = ToggleButton.Position
  199.     end
  200. end)
  201.  
  202. ToggleButton.InputChanged:Connect(function(input)
  203.     if input.UserInputType == Enum.UserInputType.MouseMovement then
  204.         dragInput = input
  205.     end
  206. end)
  207.  
  208. ToggleButton.InputEnded:Connect(function(input)
  209.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  210.         isDragging = false
  211.     end
  212. end)
  213.  
  214. userInputService.InputChanged:Connect(function(input)
  215.     if input == dragInput and isDragging then
  216.         local delta = input.Position - mousePos
  217.         ToggleButton.Position = UDim2.new(
  218.             framePos.X.Scale, framePos.X.Offset + delta.X,
  219.             framePos.Y.Scale, framePos.Y.Offset + delta.Y
  220.         )
  221.     end
  222. end)
  223.  
  224. ToggleButton.MouseButton1Click:Connect(function()
  225.     settings.espEnabled = not settings.espEnabled
  226.     if settings.espEnabled then
  227.         ToggleButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  228.         ToggleButton.Text = "ESP ON"
  229.     else
  230.         ToggleButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  231.         ToggleButton.Text = "ESP OFF"
  232.     end
  233. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement