Advertisement
some1idkxdd

ESP Script

Mar 22nd, 2025
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.84 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3. local UserInputService = game:GetService("UserInputService")
  4. local Camera = workspace.CurrentCamera
  5. local LocalPlayer = Players.LocalPlayer
  6.  
  7. local tracers = {}
  8. local boxes = {}
  9. local espEnabled = true -- Toggle flag
  10.  
  11. -- Create GUI
  12. local screenGui = Instance.new("ScreenGui")
  13. screenGui.Name = "ESPInfoGui"
  14. screenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")
  15. screenGui.ResetOnSpawn = false
  16.  
  17. -- Create the main light blue frame
  18. local mainFrame = Instance.new("Frame")
  19. mainFrame.Size = UDim2.new(0, 300, 0, 150)
  20. mainFrame.Position = UDim2.new(0.5, -150, 0.5, -75)
  21. mainFrame.BackgroundColor3 = Color3.fromRGB(173, 216, 230) -- Light blue color
  22. mainFrame.BorderSizePixel = 0
  23. mainFrame.Parent = screenGui
  24.  
  25. -- Create a label for the "Left Alt to enable/disable ESP"
  26. local espLabel = Instance.new("TextLabel")
  27. espLabel.Size = UDim2.new(1, 0, 0.5, 0)
  28. espLabel.Position = UDim2.new(0, 0, 0, 0)
  29. espLabel.BackgroundTransparency = 1
  30. espLabel.Text = "Left Alt to enable/disable ESP"
  31. espLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  32. espLabel.TextScaled = true
  33. espLabel.Font = Enum.Font.GothamBold
  34. espLabel.TextStrokeTransparency = 0.5
  35. espLabel.Parent = mainFrame
  36.  
  37. -- Create a label for the "Made by Mizzy"
  38. local madeByLabel = Instance.new("TextLabel")
  39. madeByLabel.Size = UDim2.new(1, 0, 0.5, 0)
  40. madeByLabel.Position = UDim2.new(0, 0, 0.5, 0)
  41. madeByLabel.BackgroundTransparency = 1
  42. madeByLabel.Text = "Made by Mizzy"
  43. madeByLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  44. madeByLabel.TextScaled = true
  45. madeByLabel.Font = Enum.Font.GothamBold
  46. madeByLabel.TextStrokeTransparency = 0.5
  47. madeByLabel.Parent = mainFrame
  48.  
  49. -- Create the close button (red "X")
  50. local closeButton = Instance.new("TextButton")
  51. closeButton.Size = UDim2.new(0, 40, 0, 40)  -- Smaller size: 40x40
  52. closeButton.Position = UDim2.new(1, -40, 0, 0)  -- Position adjusted to fit the smaller size
  53. closeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  54. closeButton.Text = "X"
  55. closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  56. closeButton.Font = Enum.Font.GothamBold
  57. closeButton.TextScaled = true
  58. closeButton.Parent = mainFrame
  59.  
  60. -- Function to close the GUI when the "X" button is clicked
  61. closeButton.MouseButton1Click:Connect(function()
  62.     screenGui:Destroy() -- Close the GUI
  63. end)
  64.  
  65. -- Function to apply ESP
  66. local function applyESP(player)
  67.     if player ~= LocalPlayer then
  68.         local function setup()
  69.             local character = player.Character
  70.             if not character or not character:FindFirstChild("HumanoidRootPart") then return end
  71.             if character:FindFirstChild("ESPNameTag") then return end
  72.  
  73.             -- Team check: Change ESP color based on team
  74.             local team = player.Team
  75.             local espColor = Color3.fromRGB(0, 170, 255) -- Default color (non-team)
  76.             if team then
  77.                 if team.Name == "TeamA" then
  78.                     espColor = Color3.fromRGB(0, 255, 0) -- Green for TeamA
  79.                 elseif team.Name == "TeamB" then
  80.                     espColor = Color3.fromRGB(255, 0, 0) -- Red for TeamB
  81.                 end
  82.             end
  83.  
  84.             -- Billboard name tag
  85.             local billboard = Instance.new("BillboardGui")
  86.             billboard.Parent = character
  87.             billboard.Name = "ESPNameTag"
  88.             billboard.Adornee = character:FindFirstChild("Head") or character:FindFirstChild("HumanoidRootPart")
  89.             billboard.Size = UDim2.new(0, 200, 0, 70) -- slightly taller to fit health bar
  90.             billboard.StudsOffset = Vector3.new(0, 3.5, 0)
  91.             billboard.AlwaysOnTop = true
  92.             billboard.MaxDistance = math.huge
  93.  
  94.             -- Name label
  95.             local nameLabel = Instance.new("TextLabel")
  96.             nameLabel.Parent = billboard
  97.             nameLabel.Size = UDim2.new(1, 0, 0.5, 0)
  98.             nameLabel.Position = UDim2.new(0, 0, 0, 0)
  99.             nameLabel.BackgroundTransparency = 1
  100.             nameLabel.TextColor3 = espColor
  101.             nameLabel.TextStrokeTransparency = 0
  102.             nameLabel.Text = player.Name
  103.             nameLabel.Font = Enum.Font.Legacy -- Font set to Legacy
  104.             nameLabel.TextScaled = true
  105.  
  106.             -- Health bar background
  107.             local healthBack = Instance.new("Frame")
  108.             healthBack.Parent = billboard
  109.             healthBack.Size = UDim2.new(1, -10, 0.15, 0)
  110.             healthBack.Position = UDim2.new(0, 5, 0.55, 0)
  111.             healthBack.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  112.             healthBack.BorderSizePixel = 0
  113.             healthBack.Name = "HealthBackground"
  114.  
  115.             -- Health bar foreground (the actual green bar)
  116.             local healthBar = Instance.new("Frame")
  117.             healthBar.Parent = healthBack
  118.             healthBar.Size = UDim2.new(1, 0, 1, 0)
  119.             healthBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  120.             healthBar.BorderSizePixel = 0
  121.             healthBar.Name = "HealthBar"
  122.  
  123.             -- Tracer
  124.             local tracer = Drawing.new("Line")
  125.             tracer.Thickness = 1.5
  126.             tracer.Color = espColor
  127.             tracer.Transparency = 1
  128.             tracer.Visible = true
  129.             tracers[player] = tracer
  130.  
  131.             -- Box ESP
  132.             local box = Drawing.new("Square")
  133.             box.Thickness = 1.5
  134.             box.Color = espColor
  135.             box.Transparency = 1
  136.             box.Visible = true
  137.             boxes[player] = box
  138.         end
  139.  
  140.         -- If character already exists
  141.         if player.Character then
  142.             setup()
  143.         end
  144.  
  145.         -- Or wait for character to load
  146.         player.CharacterAdded:Connect(function()
  147.             task.wait(0.5)
  148.             setup()
  149.         end)
  150.     end
  151. end
  152.  
  153. -- Cleanup when players leave
  154. Players.PlayerRemoving:Connect(function(player)
  155.     if tracers[player] then tracers[player]:Remove() tracers[player] = nil end
  156.     if boxes[player] then boxes[player]:Remove() boxes[player] = nil end
  157. end)
  158.  
  159. -- Apply ESP to all current players
  160. for _, player in ipairs(Players:GetPlayers()) do
  161.     applyESP(player)
  162. end
  163.  
  164. -- New players
  165. Players.PlayerAdded:Connect(function(player)
  166.     applyESP(player)
  167. end)
  168.  
  169. -- Toggle ESP with LeftAlt
  170. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  171.     if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftAlt then
  172.         espEnabled = not espEnabled
  173.         for _, tracer in pairs(tracers) do tracer.Visible = espEnabled end
  174.         for _, box in pairs(boxes) do box.Visible = espEnabled end
  175.         for _, player in ipairs(Players:GetPlayers()) do
  176.             if player ~= LocalPlayer and player.Character then
  177.                 local tag = player.Character:FindFirstChild("ESPNameTag")
  178.                 if tag and tag:IsA("BillboardGui") then
  179.                     tag.Enabled = espEnabled
  180.                 end
  181.             end
  182.         end
  183.     end
  184. end)
  185.  
  186. -- Update each frame
  187. RunService.RenderStepped:Connect(function()
  188.     if not espEnabled then return end
  189.  
  190.     for _, player in ipairs(Players:GetPlayers()) do
  191.         if player ~= LocalPlayer then
  192.             local character = player.Character
  193.             local hrp = character and character:FindFirstChild("HumanoidRootPart")
  194.             local head = character and character:FindFirstChild("Head")
  195.             local humanoid = character and character:FindFirstChildOfClass("Humanoid")
  196.  
  197.             local tracer = tracers[player]
  198.             local box = boxes[player]
  199.  
  200.             if character and hrp and head and humanoid and humanoid.Health > 0 then
  201.                 local top = Camera:WorldToViewportPoint(head.Position + Vector3.new(0, 0.3, 0))
  202.                 local bottom = Camera:WorldToViewportPoint(hrp.Position - Vector3.new(0, 2.5, 0))
  203.  
  204.                 local height = math.abs(top.Y - bottom.Y)
  205.                 local width = height / 2
  206.                 local boxPos = Vector2.new(top.X - width / 2, top.Y)
  207.  
  208.                 -- Update box
  209.                 if box then
  210.                     box.Position = boxPos
  211.                     box.Size = Vector2.new(width, height)
  212.                     box.Visible = true
  213.                 end
  214.  
  215.                 -- Update tracer
  216.                 if tracer then
  217.                     local rootScreenPos, onScreen = Camera:WorldToViewportPoint(hrp.Position)
  218.                     if onScreen then
  219.                         tracer.From = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y)
  220.                         tracer.To = Vector2.new(rootScreenPos.X, rootScreenPos.Y)
  221.                         tracer.Visible = true
  222.                     else
  223.                         tracer.Visible = false
  224.                     end
  225.                 end
  226.  
  227.                 -- Update health bar
  228.                 local tag = character:FindFirstChild("ESPNameTag")
  229.                 if tag and tag:FindFirstChild("HealthBackground") then
  230.                     local healthBar = tag.HealthBackground:FindFirstChild("HealthBar")
  231.                     if healthBar and humanoid then
  232.                         local healthRatio = humanoid.Health / humanoid.MaxHealth
  233.                         healthBar.Size = UDim2.new(math.clamp(healthRatio, 0, 1), 0, 1, 0)
  234.                         if healthRatio > 0.5 then
  235.                             healthBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  236.                         elseif healthRatio > 0.2 then
  237.                             healthBar.BackgroundColor3 = Color3.fromRGB(255, 165, 0)
  238.                         else
  239.                             healthBar.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  240.                         end
  241.                     end
  242.                 end
  243.             else
  244.                 if box then box.Visible = false end
  245.                 if tracer then tracer.Visible = false end
  246.             end
  247.         end
  248.     end
  249. end)
  250.  
  251. -- Delay showing the GUI by 1 second
  252. wait(1)
  253. screenGui.Enabled = true
Tags: esp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement