Advertisement
Eproq012

E

Sep 15th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.53 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3. local UserInputService = game:GetService("UserInputService")
  4. local LocalPlayer = Players.LocalPlayer
  5. local CamlockState = false
  6. local Prediction = 0.16289706
  7. local ESPBillboard = nil -- Store the ESP for the Camlock target
  8. local currentTarget = nil -- Store the current target for Camlock
  9.  
  10. -- Function to find the nearest enemy
  11. function FindNearestEnemy()
  12. local ClosestDistance, ClosestPlayer = math.huge, nil
  13. local CenterPosition = Vector2.new(game:GetService("GuiService"):GetScreenResolution().X / 2, game:GetService("GuiService"):GetScreenResolution().Y / 2)
  14.  
  15. for _, Player in ipairs(Players:GetPlayers()) do
  16. if Player ~= LocalPlayer then
  17. local Character = Player.Character
  18. if Character and Character:FindFirstChild("HumanoidRootPart") and Character.Humanoid.Health > 0 then
  19. local Position, IsVisibleOnViewport = game.Workspace.CurrentCamera:WorldToViewportPoint(Character.HumanoidRootPart.Position)
  20. if IsVisibleOnViewport then
  21. local Distance = (CenterPosition - Vector2.new(Position.X, Position.Y)).Magnitude
  22. if Distance < ClosestDistance then
  23. ClosestPlayer = Character.HumanoidRootPart
  24. ClosestDistance = Distance
  25. end
  26. end
  27. end
  28. end
  29. end
  30.  
  31. return ClosestPlayer
  32. end
  33.  
  34. -- Function to create ESP for the Camlock target
  35. local function CreateESP(Part, PlayerName)
  36. -- Remove the previous ESP if it exists
  37. if ESPBillboard then
  38. ESPBillboard:Destroy()
  39. ESPBillboard = nil
  40. end
  41.  
  42. -- Create the BillboardGui for the ESP
  43. local Billboard = Instance.new("BillboardGui")
  44. Billboard.Name = PlayerName .. "_ESP"
  45. Billboard.Adornee = Part
  46. Billboard.Size = UDim2.new(0, 200, 0, 50) -- ESP label size
  47. Billboard.StudsOffset = Vector3.new(0, 3, 0) -- Offset the ESP above the target
  48. Billboard.AlwaysOnTop = true
  49. Billboard.Parent = game.CoreGui
  50.  
  51. -- Create the TextLabel to show the player's name
  52. local TextLabel = Instance.new("TextLabel")
  53. TextLabel.Size = UDim2.new(1, 0, 1, 0)
  54. TextLabel.BackgroundTransparency = 1
  55. TextLabel.Text = PlayerName
  56. TextLabel.TextSize = 14
  57. TextLabel.TextStrokeTransparency = 0.5
  58. TextLabel.TextColor3 = Color3.fromRGB(0, 255, 255) -- Start with ocean blue
  59. TextLabel.Font = Enum.Font.SourceSansBold
  60. TextLabel.Parent = Billboard
  61.  
  62. -- Store the ESP object for removal later
  63. ESPBillboard = Billboard
  64.  
  65. -- Start the ocean-blue rainbow effect
  66. spawn(function()
  67. local hue = 180
  68. while ESPBillboard and ESPBillboard.Parent do
  69. local color = Color3.fromHSV(hue / 360, 0.8, 1)
  70. TextLabel.TextColor3 = color
  71. hue = (hue + 1) % 360
  72. if hue < 180 or hue > 240 then hue = 180 end -- Keep the hue within blue range
  73. wait(0.05)
  74. end
  75. end)
  76. end
  77.  
  78. -- Function to remove ESP when no target is selected
  79. local function RemoveESP()
  80. if ESPBillboard then
  81. ESPBillboard:Destroy()
  82. ESPBillboard = nil
  83. end
  84. end
  85.  
  86. -- Function to aim the camera at the nearest enemy's HumanoidRootPart
  87. RunService.Heartbeat:Connect(function()
  88. if CamlockState == true then
  89. if currentTarget then
  90. local camera = workspace.CurrentCamera
  91. -- Predict the target's position and adjust the camera to look at it
  92. camera.CFrame = CFrame.new(camera.CFrame.Position, currentTarget.Position + currentTarget.Velocity * Prediction)
  93. end
  94. end
  95. end)
  96.  
  97. -- Toggle the camlock and ESP when a target is locked
  98. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  99. if gameProcessed then return end -- Ignore input if the game is using the input
  100.  
  101. if input.KeyCode == Enum.KeyCode.Q then
  102. CamlockState = not CamlockState
  103. if CamlockState then
  104. currentTarget = FindNearestEnemy() -- Lock onto the nearest enemy
  105. if currentTarget then
  106. -- Activate ESP for the new target
  107. CreateESP(currentTarget, currentTarget.Parent.Name)
  108. end
  109. else
  110. -- Disable Camlock and remove ESP
  111. currentTarget = nil
  112. RemoveESP()
  113. end
  114. end
  115. end)
  116.  
  117. -- PURIFY UI Setup (for controlling Camlock and ESP)
  118. local PURIFY = Instance.new("ScreenGui")
  119. local Frame = Instance.new("Frame")
  120. local UICorner = Instance.new("UICorner")
  121. local TextButton = Instance.new("TextButton")
  122. local UICorner_2 = Instance.new("UICorner")
  123. local UIStroke = Instance.new("UIStroke")
  124.  
  125. -- Properties
  126. PURIFY.Name = "PURIFY"
  127. PURIFY.Parent = game.CoreGui
  128. PURIFY.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  129.  
  130. Frame.Parent = PURIFY
  131. Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Pure black for a sleek look
  132. Frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
  133. Frame.BorderSizePixel = 0
  134. Frame.Position = UDim2.new(0.133798108, 0, 0.20107238, 0)
  135. Frame.Size = UDim2.new(0, 202, 0, 70)
  136. Frame.Active = true
  137. Frame.Draggable = true
  138.  
  139. UICorner.Parent = Frame
  140.  
  141. TextButton.Parent = Frame
  142. TextButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  143. TextButton.BackgroundTransparency = 5.000
  144. TextButton.BorderColor3 = Color3.fromRGB(0, 0, 0)
  145. TextButton.BorderSizePixel = 0
  146. TextButton.Position = UDim2.new(0.0792079195, 0, 0.18571429, 0)
  147. TextButton.Size = UDim2.new(0, 170, 0, 44)
  148. TextButton.Font = Enum.Font.SourceSansSemibold
  149. TextButton.Text = "PURIFY OFF" -- Initial text when Camlock is off
  150. TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  151. TextButton.TextScaled = true
  152. TextButton.TextSize = 11.000
  153. TextButton.TextWrapped = true
  154.  
  155. -- Add UIStroke for sea-blue gradient effect
  156. UIStroke.Parent = Frame
  157. UIStroke.Thickness = 2
  158. UIStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
  159. UIStroke.Color = Color3.fromRGB(0, 255, 255) -- Initial sea blue color
  160.  
  161. -- Toggle the camlock and PURIFY mode on button click
  162. TextButton.MouseButton1Click:Connect(function()
  163. CamlockState = not CamlockState
  164. TextButton.Text = CamlockState and "PURIFY ON" or "PURIFY OFF" -- Toggle between ON and OFF
  165. if CamlockState then
  166. currentTarget = FindNearestEnemy()
  167. if currentTarget then
  168. CreateESP(currentTarget, currentTarget.Parent.Name) -- Activate ESP for the target
  169. end
  170. else
  171. currentTarget = nil
  172. RemoveESP() -- Remove ESP when Camlock is turned off
  173. end
  174. end)
  175.  
  176. UICorner_2.Parent = TextButton
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement