Suteishia

Roblox Box Esp, Health Bar Script

Mar 6th, 2021
835
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Brought to you by Noa#4479
  2.  
  3. --https://discord.gg/Mkpq3gr4S4
  4. --https://www.synaptic.icu/
  5.  
  6.  
  7. --// Settings:
  8. local Box_Color = Color3.fromRGB(255, 0, 0)
  9. local Tracer_Color = Color3.fromRGB(255, 0, 0)
  10. local HealthBar_Color = Color3.fromRGB(0, 255, 0)
  11.  
  12. local Tracer_Thickness = 1
  13. local Box_Thickness = 2
  14.  
  15. local teamcheck = {
  16.     teamcheck = true,
  17.     green = Color3.fromRGB(161, 242, 19),
  18.     red = Color3.fromRGB(245, 69, 5)
  19. }
  20.  
  21. --//Locals
  22. local plr = game.Players.LocalPlayer
  23. local camera = game.Workspace.CurrentCamera
  24.  
  25. local function NewQuad(thickness, color)
  26.     local quad = Drawing.new("Quad")
  27.     quad.Visible = false
  28.     quad.PointA = Vector2.new(0,0)
  29.     quad.PointB = Vector2.new(0,0)
  30.     quad.PointC = Vector2.new(0,0)
  31.     quad.PointD = Vector2.new(0,0)
  32.     quad.Color = color
  33.     quad.Filled = false
  34.     quad.Thickness = thickness
  35.     quad.Transparency = 1
  36.     return quad
  37. end
  38.  
  39. local function NewLine(thickness, color)
  40.     local line = Drawing.new("Line")
  41.     line.Visible = false
  42.     line.From = Vector2.new(0, 0)
  43.     line.To = Vector2.new(0, 0)
  44.     line.Color = color
  45.     line.Thickness = thickness
  46.     line.Transparency = 1
  47.     return line
  48. end
  49.  
  50. local black = Color3.fromRGB(0, 0, 0)
  51.  
  52. for i, v in pairs(game.Players:GetChildren()) do
  53.     local library = {
  54.         --//Tracer and Black Tracer(black border)
  55.         blacktracer = NewLine(Tracer_Thickness*2, black),
  56.         tracer = NewLine(Tracer_Thickness, Tracer_Color),
  57.         --//Box and Black Box(black border)
  58.         black = NewQuad(Box_Thickness*2, black),
  59.         box = NewQuad(Box_Thickness, Box_Color),
  60.         --//Bar and Green Health Bar (part that moves up/down)
  61.         healthbar = NewLine(8, black),
  62.         greenhealth = NewLine(4, HealthBar_Color)
  63.     }
  64.  
  65.     local function Visibility(state)
  66.         for u, x in pairs(library) do
  67.             x.Visible = state
  68.         end
  69.     end
  70.  
  71.     local function ESP()
  72.         local connection
  73.         connection = game:GetService("RunService").RenderStepped:Connect(function()
  74.             if v.Character ~= nil and v.Character:FindFirstChild("Humanoid") ~= nil and v.Character:FindFirstChild("HumanoidRootPart") ~= nil and v.Name ~= plr.Name and v.Character.Humanoid.Health > 0 and v.Character:FindFirstChild("Head") ~= nil then
  75.                 local ScreenPos, OnScreen = camera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  76.                 if OnScreen then
  77.                     local head = camera:WorldToViewportPoint(v.Character.Head.Position)
  78.                     local rootpos = camera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  79.  
  80.                     local ratio = math.clamp((Vector2.new(head.X, head.Y) - Vector2.new(rootpos.X, rootpos.Y)).magnitude, 2, math.huge)
  81.  
  82.                     local head2 = camera:WorldToViewportPoint(Vector3.new(v.Character.Head.Position.X, v.Character.Head.Position.Y + 2, v.Character.Head.Position.Z))
  83.  
  84.                     local root2 = camera:WorldToViewportPoint(Vector3.new(v.Character.Head.Position.X, v.Character.HumanoidRootPart.Position.Y - 3, v.Character.Head.Position.Z))
  85.  
  86.                     library.black.PointA = Vector2.new(head2.X + ratio*1.6, head2.Y - ratio*0.05)
  87.                     library.black.PointB = Vector2.new(head2.X - ratio*1.6, head2.Y - ratio*0.05)
  88.                     library.black.PointC = Vector2.new(head2.X - ratio*1.6, root2.Y + ratio*0.5)
  89.                     library.black.PointD = Vector2.new(head2.X + ratio*1.6, root2.Y + ratio*0.5)
  90.  
  91.                     library.box.PointA = Vector2.new(head2.X + ratio*1.6, head2.Y - ratio*0.05)
  92.                     library.box.PointB = Vector2.new(head2.X - ratio*1.6, head2.Y - ratio*0.05)
  93.                     library.box.PointC = Vector2.new(head2.X - ratio*1.6, root2.Y + ratio*0.5)
  94.                     library.box.PointD = Vector2.new(head2.X + ratio*1.6, root2.Y + ratio*0.5)
  95.  
  96.                     library.tracer.To = Vector2.new(root2.X, root2.Y + ratio*0.5)
  97.                     library.tracer.From = Vector2.new(camera.ViewportSize.X*0.5, camera.ViewportSize.Y)
  98.  
  99.                     library.blacktracer.To = Vector2.new(root2.X, root2.Y + ratio*0.5)
  100.                     library.blacktracer.From = Vector2.new(camera.ViewportSize.X*0.5, camera.ViewportSize.Y)
  101.  
  102.                     local d = (Vector2.new(head2.X - ratio*1.8, head2.Y - ratio*0.05) - Vector2.new(root2.X - ratio*1.8, root2.Y + ratio*0.5)).magnitude
  103.                     local green = (100-v.Character.Humanoid.Health) *d /100
  104.  
  105.                     library.greenhealth.Thickness = math.clamp(ratio/4, 1, 4)
  106.                     library.healthbar.Thickness = math.clamp(ratio * 1.2 / 4, 1.5, 6)
  107.  
  108.                     library.healthbar.To = Vector2.new(head2.X - ratio*1.8, head2.Y - ratio*0.05)
  109.                     library.healthbar.From = Vector2.new(head2.X - ratio*1.8, root2.Y + ratio*0.5)
  110.  
  111.                     library.greenhealth.To = Vector2.new(head2.X - ratio*1.8, head2.Y + green - ratio*0.05)
  112.                     library.greenhealth.From = Vector2.new(head2.X - ratio*1.8, root2.Y + ratio*0.5)
  113.  
  114.                     if teamcheck.teamcheck == true then
  115.                         if v.TeamColor == plr.TeamColor then
  116.                             library.box.Color = teamcheck.green
  117.                             library.tracer.Color = teamcheck.green
  118.                         else
  119.                             library.box.Color = teamcheck.red
  120.                             library.tracer.Color = teamcheck.red
  121.                         end
  122.                     end
  123.  
  124.                     Visibility(true)
  125.                 else
  126.                     Visibility(false)
  127.                 end
  128.             else
  129.                 Visibility(false)
  130.                 if game.Players:FindFirstChild(v.Name) == nil then
  131.                     connection:Disconnect()
  132.                 end
  133.             end
  134.         end)
  135.     end
  136.     coroutine.wrap(ESP)()
  137. end
  138.  
  139. game.Players.PlayerAdded:Connect(function(newplr) --Parameter gets the new player that has been added
  140.     local library = {
  141.         --//Tracer and Black Tracer(black border)
  142.         blacktracer = NewLine(Tracer_Thickness*2, black),
  143.         tracer = NewLine(Tracer_Thickness, Tracer_Color),
  144.         --//Box and Black Box(black border)
  145.         black = NewQuad(Box_Thickness*2, black),
  146.         box = NewQuad(Box_Thickness, Box_Color),
  147.         --//Bar and Green Health Bar (part that moves up/down)
  148.         healthbar = NewLine(8, black),
  149.         greenhealth = NewLine(4, HealthBar_Color)
  150.     }
  151.  
  152.     local function Visibility(state)
  153.         for u, x in pairs(library) do
  154.             x.Visible = state
  155.         end
  156.     end
  157.  
  158.     local function ESP()
  159.         local connection
  160.         connection = game:GetService("RunService").RenderStepped:Connect(function()
  161.             if newplr.Character ~= nil and newplr.Character:FindFirstChild("Humanoid") ~= nil and newplr.Character:FindFirstChild("HumanoidRootPart") ~= nil and newplr.Name ~= plr.Name and newplr.Character.Humanoid.Health > 0 and newplr.Character:FindFirstChild("Head") ~= nil then
  162.                 local ScreenPos, OnScreen = camera:WorldToViewportPoint(newplr.Character.HumanoidRootPart.Position)
  163.                 if OnScreen then
  164.                     local head = camera:WorldToViewportPoint(newplr.Character.Head.Position)
  165.                     local rootpos = camera:WorldToViewportPoint(newplr.Character.HumanoidRootPart.Position)
  166.  
  167.                     local ratio = math.clamp((Vector2.new(head.X, head.Y) - Vector2.new(rootpos.X, rootpos.Y)).magnitude, 2, math.huge)
  168.  
  169.                     local head2 = camera:WorldToViewportPoint(Vector3.new(newplr.Character.Head.Position.X, newplr.Character.Head.Position.Y + 2, newplr.Character.Head.Position.Z))
  170.  
  171.                     local root2 = camera:WorldToViewportPoint(Vector3.new(newplr.Character.Head.Position.X, newplr.Character.HumanoidRootPart.Position.Y - 3, newplr.Character.Head.Position.Z))
  172.  
  173.                     library.black.PointA = Vector2.new(head2.X + ratio*1.6, head2.Y - ratio*0.05)
  174.                     library.black.PointB = Vector2.new(head2.X - ratio*1.6, head2.Y - ratio*0.05)
  175.                     library.black.PointC = Vector2.new(head2.X - ratio*1.6, root2.Y + ratio*0.5)
  176.                     library.black.PointD = Vector2.new(head2.X + ratio*1.6, root2.Y + ratio*0.5)
  177.  
  178.                     library.box.PointA = Vector2.new(head2.X + ratio*1.6, head2.Y - ratio*0.05)
  179.                     library.box.PointB = Vector2.new(head2.X - ratio*1.6, head2.Y - ratio*0.05)
  180.                     library.box.PointC = Vector2.new(head2.X - ratio*1.6, root2.Y + ratio*0.5)
  181.                     library.box.PointD = Vector2.new(head2.X + ratio*1.6, root2.Y + ratio*0.5)
  182.  
  183.                     library.tracer.To = Vector2.new(root2.X, root2.Y + ratio*0.5)
  184.                     library.tracer.From = Vector2.new(camera.ViewportSize.X*0.5, camera.ViewportSize.Y)
  185.  
  186.                     library.blacktracer.To = Vector2.new(root2.X, root2.Y + ratio*0.5)
  187.                     library.blacktracer.From = Vector2.new(camera.ViewportSize.X*0.5, camera.ViewportSize.Y)
  188.  
  189.                     local d = (Vector2.new(head2.X - ratio*1.8, head2.Y - ratio*0.05) - Vector2.new(root2.X - ratio*1.8, root2.Y + ratio*0.5)).magnitude
  190.                     local green = (100-newplr.Character.Humanoid.Health) *d /100
  191.  
  192.                     library.greenhealth.Thickness = math.clamp(ratio/4, 1, 4)
  193.                     library.healthbar.Thickness = math.clamp(ratio * 1.2 / 4, 1.5, 6)
  194.  
  195.                     library.healthbar.To = Vector2.new(head2.X - ratio*1.8, head2.Y - ratio*0.05)
  196.                     library.healthbar.From = Vector2.new(head2.X - ratio*1.8, root2.Y + ratio*0.5)
  197.  
  198.                     library.greenhealth.To = Vector2.new(head2.X - ratio*1.8, head2.Y + green - ratio*0.05)
  199.                     library.greenhealth.From = Vector2.new(head2.X - ratio*1.8, root2.Y + ratio*0.5)
  200.  
  201.                     if teamcheck.teamcheck == true then
  202.                         if newplr.TeamColor == plr.TeamColor then
  203.                             library.box.Color = teamcheck.green
  204.                             library.tracer.Color = teamcheck.green
  205.                         else
  206.                             library.box.Color = teamcheck.red
  207.                             library.tracer.Color = teamcheck.red
  208.                         end
  209.                     end
  210.  
  211.                     Visibility(true)
  212.                 else
  213.                     Visibility(false)
  214.                 end
  215.             else
  216.                 Visibility(false)
  217.                 if game.Players:FindFirstChild(newplr.Name) == nil then
  218.                     connection:Disconnect()
  219.                 end
  220.             end
  221.         end)
  222.     end
  223.     coroutine.wrap(ESP)()
  224. end)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×