Advertisement
Eproq012

Untitled

Sep 17th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local RunService = game:GetService("RunService")
  3. local UserInputService = game:GetService("UserInputService")
  4. local Stats = game:GetService("Stats")
  5. local LocalPlayer = Players.LocalPlayer
  6. local CamlockState = false
  7. local Prediction = 0.14376
  8. local ESPBillboard = nil
  9. local currentTarget = nil
  10. local lastPing = 0
  11. local pingUpdateInterval = 1 -- Update the prediction every 1 second for performance reasons
  12. local lastPingUpdateTime = tick()
  13. local smoothingFactor = 0.3 -- Controls how smooth the camera transition is
  14.  
  15. -- Function to find the nearest enemy
  16. function FindNearestEnemy()
  17. local ClosestDistance, ClosestPlayer = math.huge, nil
  18. local CenterPosition = Vector2.new(game.Workspace.CurrentCamera.ViewportSize.X / 2, game.Workspace.CurrentCamera.ViewportSize.Y / 2)
  19.  
  20. for _, Player in ipairs(Players:GetPlayers()) do
  21. if Player ~= LocalPlayer then
  22. local Character = Player.Character
  23. if Character and Character:FindFirstChild("HumanoidRootPart") and Character.Humanoid.Health > 0 then
  24. local Position, IsVisibleOnViewport = game.Workspace.CurrentCamera:WorldToViewportPoint(Character.HumanoidRootPart.Position)
  25. if IsVisibleOnViewport then
  26. local Distance = (CenterPosition - Vector2.new(Position.X, Position.Y)).Magnitude
  27. if Distance < ClosestDistance then
  28. ClosestPlayer = Character.HumanoidRootPart
  29. ClosestDistance = Distance
  30. end
  31. end
  32. end
  33. end
  34. end
  35.  
  36. return ClosestPlayer
  37. end
  38.  
  39. -- Optimized Auto Prediction Function (updates less frequently)
  40. local function UpdatePrediction()
  41. local ping = Stats.Network.ServerStatsItem["Data Ping"]:GetValue() -- Get current ping
  42.  
  43. -- Update only if ping changes significantly or at the update interval
  44. if math.abs(ping - lastPing) > 10 or (tick() - lastPingUpdateTime) >= pingUpdateInterval then
  45. lastPingUpdateTime = tick()
  46. lastPing = ping
  47.  
  48. -- Set prediction value based on ping
  49. if ping >= 1000 then
  50. Prediction = 0.345
  51. elseif ping >= 900 then
  52. Prediction = 0.290724
  53. elseif ping >= 800 then
  54. Prediction = 0.254408
  55. elseif ping >= 700 then
  56. Prediction = 0.23398
  57. elseif ping >= 600 then
  58. Prediction = 0.215823
  59. elseif ping >= 500 then
  60. Prediction = 0.19284
  61. elseif ping >= 400 then
  62. Prediction = 0.18321
  63. elseif ping >= 360 then
  64. Prediction = 0.16537
  65. elseif ping >= 280 then
  66. Prediction = 0.16780
  67. elseif ping >= 270 then
  68. Prediction = 0.195566
  69. elseif ping >= 260 then
  70. Prediction = 0.175566
  71. elseif ping >= 250 then
  72. Prediction = 0.1651
  73. elseif ping >= 240 then
  74. Prediction = 0.16780
  75. elseif ping >= 230 then
  76. Prediction = 0.15692
  77. elseif ping >= 220 then
  78. Prediction = 0.165566
  79. elseif ping >= 210 then
  80. Prediction = 0.165566
  81. elseif ping >= 200 then
  82. Prediction = 0.16942
  83. elseif ping >= 190 then
  84. Prediction = 0.166547
  85. elseif ping >= 180 then
  86. Prediction = 0.19284
  87. elseif ping >= 170 then
  88. Prediction = 0.1923111
  89. elseif ping >= 160 then
  90. Prediction = 0.16
  91. elseif ping >= 150 then
  92. Prediction = 0.15
  93. elseif ping >= 140 then
  94. Prediction = 0.1223333
  95. elseif ping >= 130 then
  96. Prediction = 0.156692
  97. elseif ping >= 120 then
  98. Prediction = 0.14376
  99. elseif ping >= 110 then
  100. Prediction = 0.1455
  101. elseif ping >= 100 then
  102. Prediction = 0.130340
  103. elseif ping >= 90 then
  104. Prediction = 0.136
  105. elseif ping >= 80 then
  106. Prediction = 0.1347
  107. elseif ping >= 70 then
  108. Prediction = 0.119
  109. elseif ping >= 60 then
  110. Prediction = 0.12731
  111. elseif ping >= 50 then
  112. Prediction = 0.127668
  113. elseif ping >= 40 then
  114. Prediction = 0.125
  115. elseif ping >= 30 then
  116. Prediction = 0.11
  117. elseif ping >= 20 then
  118. Prediction = 0.12588
  119. elseif ping >= 10 then
  120. Prediction = 0.9
  121. else
  122. Prediction = 0.1 -- Default minimum prediction for very low ping
  123. end
  124. end
  125. end
  126.  
  127. -- Function to smoothly aim the camera at the nearest enemy's HumanoidRootPart with auto prediction
  128. RunService.Heartbeat:Connect(function()
  129. if CamlockState == true then
  130. if currentTarget then
  131. local camera = workspace.CurrentCamera
  132. -- Predict the target's position and adjust the camera to look at it smoothly using Lerp
  133. local predictedPosition = currentTarget.Position + currentTarget.Velocity * Prediction
  134. local targetCFrame = CFrame.new(camera.CFrame.Position, predictedPosition)
  135. camera.CFrame = camera.CFrame:Lerp(targetCFrame, smoothingFactor) -- Lerp the camera smoothly to the target
  136. end
  137. end
  138. end)
  139.  
  140. -- Continuously update prediction based on ping, but less frequently for performance
  141. RunService.Heartbeat:Connect(function()
  142. UpdatePrediction()
  143. end)
  144.  
  145. -- Toggle the camlock when a target is locked
  146. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  147. if gameProcessed then return end -- Ignore input if the game is using the input
  148.  
  149. if input.KeyCode == Enum.KeyCode.Q then
  150. CamlockState = not CamlockState
  151. if CamlockState then
  152. currentTarget = FindNearestEnemy() -- Lock onto the nearest enemy
  153. else
  154. -- Disable Camlock
  155. currentTarget = nil
  156. end
  157. end
  158. end)
  159.  
  160. -- PURIFY UI Setup (for controlling Camlock)
  161. local PURIFY = Instance.new("ScreenGui")
  162. local Frame = Instance.new("Frame")
  163. local UICorner = Instance.new("UICorner")
  164. local TextButton = Instance.new("TextButton")
  165. local UICorner_2 = Instance.new("UICorner")
  166. local UIStroke = Instance.new("UIStroke")
  167.  
  168. -- Properties
  169. PURIFY.Name = "PURIFY"
  170. PURIFY.Parent = game.CoreGui
  171. PURIFY.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  172.  
  173. Frame.Parent = PURIFY
  174. Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Pure black for a sleek look
  175. Frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
  176. Frame.BorderSizePixel = 0
  177. Frame.Position = UDim2.new(0.133798108, 0, 0.20107238, 0)
  178. Frame.Size = UDim2.new(0, 202, 0, 70)
  179. Frame.Active = true
  180. Frame.Draggable = true
  181.  
  182. UICorner.Parent = Frame
  183.  
  184. TextButton.Parent = Frame
  185. TextButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  186. TextButton.BackgroundTransparency = 5.000
  187. TextButton.BorderColor3 = Color3.fromRGB(0, 0, 0)
  188. TextButton.BorderSizePixel = 0
  189. TextButton.Position = UDim2.new(0.0792079195, 0, 0.18571429, 0)
  190. TextButton.Size = UDim2.new(0, 170, 0, 44)
  191. TextButton.Font = Enum.Font.SourceSansSemibold
  192. TextButton.Text = "PURIFY OFF" -- Initial text when Camlock is off
  193. TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  194. TextButton.TextScaled = true
  195. TextButton.TextSize = 11.000
  196. TextButton.TextWrapped = true
  197.  
  198. -- Add UIStroke for sea-blue gradient effect
  199. UIStroke.Parent = Frame
  200. UIStroke.Thickness = 2
  201. UIStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
  202. UIStroke.Color = Color3.fromRGB(0, 255, 255) -- Initial sea blue color
  203.  
  204. UICorner_2.Parent = TextButton
  205.  
  206. -- Toggle the camlock and PURIFY mode on button click
  207. TextButton.MouseButton1Click:Connect(function()
  208. CamlockState = not CamlockState
  209. TextButton.Text = CamlockState and "PURIFY ON" or "PURIFY OFF" -- Toggle between ON and OFF
  210. if CamlockState then
  211. currentTarget = FindNearestEnemy()
  212. else
  213. currentTarget = nil
  214. end
  215. end)
  216.  
  217. -- Create an ocean-blue rainbow effect for the button and the frame
  218. spawn(function()
  219. local hue = 180
  220. while true do
  221. -- Calculate the current color in the blue range (hue 180-240)
  222. local color = Color3.fromHSV(hue / 360, 0.8, 1)
  223.  
  224. -- Apply the color to the text and stroke
  225. TextButton.TextColor3 = color
  226. UIStroke.Color = color
  227.  
  228. -- Increment the hue for the rainbow effect
  229. hue = hue + 1
  230. if hue > 240 then
  231. hue = 180 -- Reset to start of ocean blue range
  232. end
  233.  
  234. wait(0.05) -- Controls how fast the rainbow effect changes
  235. end
  236. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement