Advertisement
boboh

Untitled

Mar 19th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. local standartESP = {}
  2.  
  3. local localPlayer = game:GetService("Players").LocalPlayer
  4. local currentCamera = workspace.CurrentCamera
  5. local worldToViewportPoint = currentCamera.WorldToViewportPoint
  6. local setmetatable = setmetatable
  7. local newDrawing = Drawing.new
  8. local newVector2 = Vector2.new
  9. local newVector3 = Vector3.new
  10. local remove = table.remove
  11.  
  12. local headOffset = newVector3(0, 0.5, 0)
  13. local legOffset = newVector3(0, 3, 0)
  14. local tracerStart = newVector2(currentCamera.ViewportSize.X / 2, currentCamera.ViewportSize.Y)
  15.  
  16. function standartESP.new(data)
  17. local self =
  18. setmetatable(
  19. {
  20. plr = data.plr,
  21. char = data.plr.Character,
  22. espBox = nil,
  23. name = nil,
  24. tracer = nil,
  25. espColor = data.espColor or fromRGB(255, 255, 255),
  26. teamCheck = data.teamCheck or false
  27. },
  28. {__index = OwlESP}
  29. )
  30.  
  31. local plr = data.plr
  32. local char = self.char
  33. local espBoxVisible = data.espBoxVisible
  34. local tracerVisible = data.tracerVisible
  35. local text = data.text
  36.  
  37. if not char then
  38. return
  39. end
  40.  
  41. local rootPart = char.HumanoidRootPart
  42. local head = char.Head
  43. local rootPos, rootVis = worldToViewportPoint(currentCamera, rootPart.Position)
  44. local headPos = worldToViewportPoint(currentCamera, head.Position + headOffset)
  45. local legPos = worldToViewportPoint(currentCamera, rootPart.Position - legOffset)
  46. local visible = (self.teamCheck and plr.TeamColor ~= localPlayer.TeamColor) or (not self.teamCheck)
  47.  
  48. local espBox = newDrawing("Square")
  49. espBox.Color = self.espColor
  50. espBox.Thickness = 2
  51. espBox.Filled = false
  52. espBox.Transparency = 0.8
  53. local tracer = newDrawing("Line")
  54. tracer.From = tracerStart
  55. tracer.Color = self.espColor
  56. tracer.Thickness = 2
  57. tracer.Transparency = 0.8
  58. local name = newDrawing("Text")
  59. name.Text = text
  60. name.Size = 16
  61. name.Color = self.espColor
  62. name.Center = true
  63. name.Outline = true
  64.  
  65. if rootVis then
  66. espBox.Size = newVector2(2350 / rootPos.Z, headPos.Y - legPos.Y)
  67. espBox.Position = newVector2(rootPos.X - espBox.Size.X / 2, rootPos.Y - espBox.Size.Y / 2)
  68. tracer.To = newVector2(rootPos.X, rootPos.Y - espBox.Size.Y / 2)
  69. name.Position = newVector2(rootPos.X, (rootPos.Y + espBox.Size.Y / 2) - 25)
  70.  
  71. espBox.Visible = espBoxVisible and visible
  72. tracer.Visible = tracerVisible and visible
  73. name.Visible = visible
  74. end
  75.  
  76. self.espBox = {espBox, espBoxVisible}
  77. self.tracer = {tracer, tracerVisible}
  78. self.name = {name, text}
  79.  
  80. return self
  81. end
  82.  
  83. function standartESP:setESPBox(visible)
  84. self.espBox[2] = visible
  85. end
  86.  
  87. function standartESP:setTracer(visible)
  88. self.tracer[2] = visible
  89. end
  90.  
  91. function standartESP:setText(text)
  92. self.name[2] = text
  93. end
  94.  
  95. function standartESP:update()
  96. local plr, char, espBox, tracer, name = self.plr, self.char, self.espBox[1], self.tracer[1], self.name[1]
  97. local espBoxVisible, tracerVisible, text, espColor = self.espBox[2], self.tracer[2], self.name[2], self.espColor
  98. local rootPart, head = char:FindFirstChild("HumanoidRootPart"), char:FindFirstChild("Head")
  99.  
  100. if rootPart and head then
  101. local rootPos, rootVis = worldToViewportPoint(currentCamera, rootPart.Position)
  102. local headPos = worldToViewportPoint(currentCamera, head.Position + headOffset)
  103. local legPos = worldToViewportPoint(currentCamera, rootPart.Position - legOffset)
  104. local visible = (self.teamCheck and plr.TeamColor ~= localPlayer.TeamColor) or (not self.teamCheck)
  105.  
  106. if rootVis then
  107. espBox.Size = newVector2(2350 / rootPos.Z, headPos.Y - legPos.Y)
  108. local espBoxSize = espBox.Size
  109. espBox.Position = newVector2(rootPos.X - espBoxSize.X / 2, rootPos.Y - espBoxSize.Y / 2)
  110. espBox.Color = espColor
  111. tracer.To = newVector2(rootPos.X, rootPos.Y - espBoxSize.Y / 2)
  112. tracer.Color = espColor
  113. name.Position = newVector2(rootPos.X, (rootPos.Y + espBoxSize.Y / 2) - 25)
  114. name.Text = text
  115. name.Color = espColor
  116.  
  117. espBox.Visible = espBoxVisible and visible
  118. tracer.Visible = tracerVisible and visible
  119. name.Visible = visible
  120. else
  121. espBox.Visible = false
  122. tracer.Visible = false
  123. name.Visible = false
  124. end
  125. end
  126. end
  127.  
  128. function standartESP:remove()
  129. self.espBox[1]:Remove()
  130. self.tracer[1]:Remove()
  131. self.name[1]:Remove()
  132. function self:update()
  133. end
  134. end
  135.  
  136. return standartESP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement