ColdSpecs

Main #2 ESP

Sep 6th, 2023
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2. local Camera = workspace.CurrentCamera
  3. local DrawingAPI = {}
  4. local function GetHead(Model)
  5. for _, Part in pairs(Model:GetChildren()) do
  6. if Part.Name == "Head" then
  7. return Part
  8. end
  9. end
  10. end
  11. local Heads = {}
  12. local function UpdateHeads()
  13. for _, Model in pairs(workspace:GetChildren()) do
  14. if Model:IsA("Model") and Model ~= game.Players.LocalPlayer.Character then
  15. local Head = GetHead(Model)
  16. if Head then
  17. Heads[Model] = Head
  18.  
  19. DrawingAPI[Model] = Drawing.new("Text")
  20. DrawingAPI[Model].Visible = false
  21. DrawingAPI[Model].Size = 20
  22. DrawingAPI[Model].Color = Color3.new(1, 1, 1)
  23. DrawingAPI[Model].Center = true
  24. DrawingAPI[Model].Outline = true
  25. end
  26. end
  27. end
  28. end
  29. UpdateHeads()
  30. workspace.ChildAdded:Connect(function(Model)
  31. if Model:IsA("Model") and Model ~= game.Players.LocalPlayer.Character then
  32. local Head = GetHead(Model)
  33. if Head then
  34. Heads[Model] = Head
  35.  
  36. DrawingAPI[Model] = Drawing.new("Text")
  37. DrawingAPI[Model].Visible = false
  38. DrawingAPI[Model].Size = 20
  39. DrawingAPI[Model].Color = Color3.new(1, 1, 1)
  40. DrawingAPI[Model].Center = true
  41. DrawingAPI[Model].Outline = true
  42. end
  43. end
  44. end)
  45. workspace.ChildRemoved:Connect(function(Model)
  46. if Heads[Model] then
  47. Heads[Model] = nil
  48.  
  49. DrawingAPI[Model]:Remove()
  50. DrawingAPI[Model] = nil
  51. end
  52. end)
  53. RunService.RenderStepped:Connect(function()
  54. for Model, Head in pairs(Heads) do
  55. local ScreenPosition, OnScreen = Camera:WorldToScreenPoint(Head.Position)
  56. if OnScreen then
  57.  
  58. DrawingAPI[Model].Visible = true
  59. DrawingAPI[Model].Position = Vector2.new(ScreenPosition.X, ScreenPosition.Y)
  60. DrawingAPI[Model].Text = " (" .. math.floor((Head.Position - Camera.CFrame.p).Magnitude) .. ")"
  61. else
  62.  
  63. DrawingAPI[Model].Visible = false
  64. end
  65. end
  66. end)
Add Comment
Please, Sign In to add comment