Advertisement
RN_MODZ

Untitled

Dec 28th, 2022 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.82 KB | None | 0 0
  1. -- Services
  2.  
  3. local Players = game:GetService("Players")
  4. local RS = game:GetService("RunService")
  5.  
  6. -- Variables
  7.  
  8. local Plr = Players.LocalPlayer
  9. local Char = Plr.Character or Plr.CharacterAdded:Wait()
  10. local Root = Char:WaitForChild("HumanoidRootPart")
  11. local Camera = workspace.CurrentCamera
  12.  
  13. local ESP = {
  14. connections = {},
  15. containers = {},
  16. settings = {
  17. distance = true,
  18. health = false,
  19. tracers = true,
  20. rainbow = false,
  21. textSize = 16,
  22. tracerFrom = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 10),
  23. tracerThickness = 1,
  24. },
  25. }
  26.  
  27. -- Functions
  28.  
  29. local function getWTVP(vec3)
  30. local wtvp, visible = Camera:WorldToViewportPoint(vec3)
  31. return Vector2.new(wtvp.X, wtvp.Y), visible
  32. end
  33.  
  34. local function GetMag(a, b)
  35. return (Vector3.new(b.X, b.Y, b.Z) - Vector3.new(a.X, a.Y, a.Z)).Magnitude
  36. end
  37.  
  38. local function objectIsPlayer(object)
  39. return object:IsDescendantOf(Players)
  40. end
  41.  
  42. function ESP:Add(object, settings)
  43. if ESP.containers[object] then
  44. ESP:Remove(object)
  45. end
  46.  
  47. local container = {
  48. connections = {},
  49. draw = {},
  50. object = object,
  51. name = settings.name or object.Name,
  52. root = settings.root or object,
  53. active = true,
  54. }
  55.  
  56. -- Construction
  57.  
  58. local displayLabel = Drawing.new("Text")
  59. local tracer = Drawing.new("Line")
  60.  
  61. local color = settings.color or (objectIsPlayer(object) and object.Team) and object.TeamColor.Color or Color3.fromRGB(255, 255, 255)
  62.  
  63. displayLabel.Center = true
  64. displayLabel.Outline = true
  65. displayLabel.Color = color
  66. displayLabel.Position = getWTVP(container.root.Position)
  67. displayLabel.Size = ESP.settings.textSize
  68.  
  69. tracer.Color = color
  70. tracer.From = ESP.settings.tracerFrom
  71. tracer.Thickness = ESP.settings.tracerThickness
  72.  
  73. -- Indexing
  74.  
  75. container.draw.display = {
  76. object = displayLabel,
  77. type = "Text",
  78. canRGB = true,
  79. originalColor = color,
  80. }
  81. container.draw.tracer = {
  82. object = tracer,
  83. type = "Tracer",
  84. offset = Vector2.new(0, ESP.settings.textSize),
  85. canRGB = true,
  86. originalColor = color,
  87. }
  88.  
  89. ESP.containers[container.object] = container
  90.  
  91. -- Scripts
  92.  
  93. container.connections.ancestryChanged = container.root.AncestryChanged:Connect(function()
  94. if container.root:IsDescendantOf(nil) then
  95. ESP:Remove(container.root)
  96. end
  97. end)
  98.  
  99. if objectIsPlayer(container.object) then
  100. container.connections.Died = container.object.Character.Humanoid.Died:Connect(function(_, p)
  101. ESP:Remove(container.root)
  102. end)
  103. end
  104.  
  105. return container
  106. end
  107.  
  108. function ESP:Remove(object)
  109. local container = ESP.containers[object]
  110. if container then
  111. container.active = false
  112.  
  113. for i, v in next, container.connections do
  114. v:Disconnect()
  115. container.connections[i] = nil
  116. end
  117. for i, v in next, container.draw do
  118. v.object:Remove()
  119. container.draw[i] = nil
  120. end
  121.  
  122. ESP.containers[object] = nil
  123. end
  124. end
  125.  
  126. function ESP:UpdateContainers()
  127. for i, v in next, ESP.containers do
  128. local rootPos, visible = getWTVP(v.root.Position)
  129. v.active = visible
  130.  
  131. if v.active then
  132. for i2, v2 in next, v.draw do
  133. if not v2.object.Visible then
  134. v2.object.Visible = true
  135. end
  136.  
  137. if v2.type == "Text" then
  138. v2.object.Size = ESP.settings.textSize
  139. v2.object.Position = rootPos + (v2.offset or Vector2.new())
  140.  
  141. elseif v2.type == "Tracer" then
  142. if ESP.settings.tracers then
  143. v2.object.From = ESP.settings.tracerFrom
  144. v2.object.To = rootPos + (v2.offset or Vector2.new())
  145. v2.object.Thickness = ESP.settings.tracerThickness
  146. else
  147. v2.object.Visible = false
  148. end
  149. end
  150. end
  151.  
  152. -- Update draws
  153.  
  154. v.draw.display.object.Text = v.name
  155.  
  156. if ESP.settings.distance then
  157. v.draw.display.object.Text = v.draw.display.object.Text.. " [".. math.floor(GetMag(Root.Position, v.root.Position)).. " distance]"
  158. end
  159.  
  160. if objectIsPlayer(v.object) and ESP.settings.health then
  161. local humanoid = v.object.Character:WaitForChild("Humanoid")
  162. if humanoid then
  163. local healthPercentage = math.floor(100 / humanoid.MaxHealth * humanoid.Health * 10) / 10
  164. v.draw.display.object.Text = v.draw.display.object.Text.. " [".. healthPercentage.. "%]"
  165. end
  166. end
  167.  
  168. -- Rainbow
  169.  
  170. for i2, v2 in next, v.draw do
  171. if v2.canRGB then
  172. v2.object.Color = ESP.settings.rainbow and Color3.fromHSV(tick() % 5 / 5, 1, 1) or v2.originalColor
  173. end
  174. end
  175. else
  176. for i2, v2 in next, v.draw do
  177. if v2.object.Visible then
  178. v2.object.Visible = false
  179. end
  180. end
  181. end
  182. end
  183. end
  184.  
  185. -- Scripts
  186.  
  187. ESP.connections.updateContainers = RS.RenderStepped:Connect(ESP.UpdateContainers)
  188.  
  189. ESP.connections.playerRemoving = Players.PlayerRemoving:Connect(function(p)
  190. for i, v in next, ESP.containers do
  191. if v.object == p then
  192. ESP:Remove(v.object)
  193. end
  194. end
  195. end)
  196.  
  197. ESP.connections.characterAdded = Plr.CharacterAdded:Connect(function(c)
  198. Char, Root = c, c:WaitForChild("HumanoidRootPart")
  199. end)
  200.  
  201. return ESP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement