benxogian

Untitled

Dec 28th, 2024
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.02 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local camera = workspace.CurrentCamera
  3. local playerGui = player:WaitForChild("PlayerGui")
  4.  
  5. local smoothSpeed = 0.9
  6. local predictionValue = 0.150
  7. local isLockedOn = false
  8. local lockedPlayer = nil
  9. local resolverActive = true
  10. local currentIndicator = nil
  11.  
  12. local function calculateDistance(a, b)
  13. return (a - b).Magnitude
  14. end
  15.  
  16. local function resolveAntiAim(targetPlayer)
  17. if targetPlayer and targetPlayer.Character then
  18. local humanoidRootPart = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
  19. if humanoidRootPart then
  20. return humanoidRootPart.Position
  21. end
  22. end
  23. return nil
  24. end
  25.  
  26. local function enhancedPrediction(targetPlayer)
  27. if targetPlayer and targetPlayer.Character then
  28. local humanoidRootPart = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
  29. local humanoid = targetPlayer.Character:FindFirstChild("Humanoid")
  30. if humanoidRootPart and humanoid then
  31. local velocity = humanoidRootPart.Velocity
  32. local predictedPosition = humanoidRootPart.Position + velocity * predictionValue
  33.  
  34. if humanoid:GetState() == Enum.HumanoidStateType.Physics then
  35. -- Adjust prediction for jump (consider vertical velocity)
  36. local verticalVelocity = velocity.Y
  37. local gravity = game:GetService("Workspace").Gravity -- Get current gravity
  38.  
  39. local jumpTime = math.abs(verticalVelocity / gravity) -- Time to reach the peak of the jump
  40. local jumpHeight = verticalVelocity * jumpTime - (0.5 * gravity * jumpTime ^ 2)
  41.  
  42. predictedPosition = humanoidRootPart.Position + velocity * predictionValue
  43. predictedPosition = predictedPosition + Vector3.new(0, jumpHeight, 0)
  44.  
  45. if resolverActive then
  46. local resolvedPosition = resolveAntiAim(targetPlayer)
  47. if resolvedPosition then
  48. predictedPosition = resolvedPosition
  49. end
  50. end
  51. end
  52. return predictedPosition
  53. end
  54. end
  55. return nil
  56. end
  57. local function enhancedPrediction(targetPlayer)
  58. if targetPlayer and targetPlayer.Character then
  59. local humanoidRootPart = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
  60. local humanoid = targetPlayer.Character:FindFirstChildOfClass("Humanoid")
  61.  
  62. if humanoidRootPart and humanoid then
  63. local velocity = humanoidRootPart.Velocity
  64. local predictedPosition = humanoidRootPart.Position + velocity * predictionValue -- Predict position based on velocity
  65.  
  66. local horizontalVelocity = Vector3.new(velocity.X, 0, velocity.Z) -- Only horizontal velocity
  67. local horizontalPrediction = humanoidRootPart.Position + horizontalVelocity * predictionValue
  68.  
  69. local gravity = workspace.Gravity
  70. local timeToFall = (-velocity.Y - math.sqrt(velocity.Y^2 - 2 * gravity * humanoidRootPart.Position.Y)) / gravity
  71. local predictedFallPosition = humanoidRootPart.Position + Vector3.new(0, velocity.Y * timeToFall + 0.5 * gravity * timeToFall^2, 0)
  72.  
  73. if velocity.Y < 0 then
  74. predictedPosition = predictedFallPosition
  75. else
  76. predictedPosition = horizontalPrediction -- For air movement, use horizontal prediction
  77. end
  78.  
  79. if resolverActive then
  80. local resolvedPosition = resolveAntiAim(targetPlayer)
  81. if resolvedPosition then
  82. predictedPosition = resolvedPosition
  83. end
  84. end
  85.  
  86. if humanoid:GetState() == Enum.HumanoidStateType.Physics then
  87. return predictedPosition -- In air, adjust fall trajectory
  88. else
  89. return horizontalPrediction -- On the ground, just use horizontal movement
  90. end
  91. end
  92. end
  93. return nil
  94. end
  95.  
  96. local function createTargetIndicator(targetPlayer)
  97. local highlight = Instance.new("Highlight")
  98. highlight.Adornee = targetPlayer.Character
  99. highlight.FillColor = Color3.new(1, 0, 0)
  100. highlight.FillTransparency = 0.5
  101. highlight.OutlineTransparency = 1
  102. highlight.Parent = targetPlayer.Character
  103. return highlight
  104. end
  105.  
  106. local function lockOn()
  107. local closestPlayer = nil
  108. local shortestDistance = math.huge
  109. local screenCenter = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
  110.  
  111. for _, p in pairs(game.Players:GetPlayers()) do
  112. if p ~= player then
  113. local character = p.Character
  114. if character and character:FindFirstChild("HumanoidRootPart") then
  115. local head = character.HumanoidRootPart
  116. local headPos = camera:WorldToScreenPoint(head.Position)
  117.  
  118. local distance = (screenCenter - Vector2.new(headPos.X, headPos.Y)).Magnitude
  119. if distance < shortestDistance then
  120. shortestDistance = distance
  121. closestPlayer = p
  122. end
  123. end
  124. end
  125. end
  126.  
  127. if closestPlayer then
  128. lockedPlayer = closestPlayer
  129. isLockedOn = true
  130. if currentIndicator then
  131. currentIndicator:Destroy()
  132. end
  133. currentIndicator = createTargetIndicator(lockedPlayer)
  134. else
  135. print("No player found to lock onto.")
  136. end
  137. end
  138.  
  139. local function smoothlyDragToPlayer(targetPlayer)
  140. if targetPlayer then
  141. local predictedPosition = enhancedPrediction(targetPlayer)
  142. if predictedPosition then
  143. local currentPosition = camera.CFrame.Position
  144. camera.CFrame = CFrame.new(currentPosition:Lerp(predictedPosition, smoothSpeed), predictedPosition)
  145. end
  146. end
  147. end
  148.  
  149. local function stopLockingOn()
  150. if currentIndicator then
  151. currentIndicator:Destroy()
  152. currentIndicator = nil
  153. end
  154. lockedPlayer = nil
  155. isLockedOn = false
  156. end
  157.  
  158. local function createGUI()
  159. local screenGui = Instance.new("ScreenGui")
  160. screenGui.Parent = playerGui
  161.  
  162. local function makeRainbow(button)
  163. local colorIndex = 0
  164. task.spawn(function()
  165. while true do
  166. colorIndex = (colorIndex + 1) % 360
  167. button.BackgroundColor3 = Color3.fromHSV(colorIndex / 360, 1, 1)
  168. button.BorderSizePixel = 2
  169. button.BorderColor3 = Color3.new(1, 1, 1)
  170. task.wait(0.05)
  171. end
  172. end)
  173. end
  174.  
  175. local lockButton = Instance.new("TextButton")
  176. lockButton.Size = UDim2.new(0, 100, 0, 50)
  177. lockButton.Position = UDim2.new(1, -110, 0, 10)
  178. lockButton.Text = "Lock On"
  179. lockButton.Font = Enum.Font.GothamBold
  180. lockButton.TextColor3 = Color3.new(1, 1, 1)
  181. lockButton.Parent = screenGui
  182. makeRainbow(lockButton)
  183.  
  184. local settingsButton = Instance.new("TextButton")
  185. settingsButton.Size = UDim2.new(0, 100, 0, 50)
  186. settingsButton.Position = UDim2.new(1, -220, 0, 10)
  187. settingsButton.Text = "Settings"
  188. settingsButton.Font = Enum.Font.GothamBold
  189. settingsButton.TextColor3 = Color3.new(1, 1, 1)
  190. settingsButton.Parent = screenGui
  191. makeRainbow(settingsButton)
  192.  
  193. local settingsFrame = Instance.new("Frame")
  194. settingsFrame.Size = UDim2.new(0, 250, 0, 200)
  195. settingsFrame.Position = UDim2.new(0.5, -125, 0.5, -100)
  196. settingsFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  197. settingsFrame.Visible = false
  198. settingsFrame.Parent = screenGui
  199.  
  200. local settingsUICorner = Instance.new("UICorner")
  201. settingsUICorner.CornerRadius = UDim.new(0, 10)
  202. settingsUICorner.Parent = settingsFrame
  203.  
  204. local smoothnessLabel = Instance.new("TextLabel")
  205. smoothnessLabel.Size = UDim2.new(0, 120, 0, 30)
  206. smoothnessLabel.Position = UDim2.new(0, 10, 0, 10)
  207. smoothnessLabel.Text = "Smoothness:"
  208. smoothnessLabel.Font = Enum.Font.Gotham
  209. smoothnessLabel.TextColor3 = Color3.new(1, 1, 1)
  210. smoothnessLabel.BackgroundTransparency = 1
  211. smoothnessLabel.Parent = settingsFrame
  212.  
  213. local smoothnessBox = Instance.new("TextBox")
  214. smoothnessBox.Size = UDim2.new(0, 100, 0, 30)
  215. smoothnessBox.Position = UDim2.new(0, 140, 0, 10)
  216. smoothnessBox.Text = tostring(smoothSpeed)
  217. smoothnessBox.Font = Enum.Font.Gotham
  218. smoothnessBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  219. smoothnessBox.TextColor3 = Color3.new(1, 1, 1)
  220. smoothnessBox.Parent = settingsFrame
  221.  
  222. local predictionLabel = Instance.new("TextLabel")
  223. predictionLabel.Size = UDim2.new(0, 120, 0, 30)
  224. predictionLabel.Position = UDim2.new(0, 10, 0, 50)
  225. predictionLabel.Text = "Prediction:"
  226. predictionLabel.Font = Enum.Font.Gotham
  227. predictionLabel.TextColor3 = Color3.new(1, 1, 1)
  228. predictionLabel.BackgroundTransparency = 1
  229. predictionLabel.Parent = settingsFrame
  230.  
  231. local predictionBox = Instance.new("TextBox")
  232. predictionBox.Size = UDim2.new(0, 100, 0, 30)
  233. predictionBox.Position = UDim2.new(0, 140, 0, 50)
  234. predictionBox.Text = tostring(predictionValue)
  235. predictionBox.Font = Enum.Font.Gotham
  236. predictionBox.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  237. predictionBox.TextColor3 = Color3.new(1, 1, 1)
  238. predictionBox.Parent = settingsFrame
  239.  
  240. local resolverLabel = Instance.new("TextLabel")
  241. resolverLabel.Size = UDim2.new(0, 120, 0, 30)
  242. resolverLabel.Position = UDim2.new(0, 10, 0, 90)
  243. resolverLabel.Text = "Resolver:"
  244. resolverLabel.Font = Enum.Font.Gotham
  245. resolverLabel.TextColor3 = Color3.new(1, 1, 1)
  246. resolverLabel.BackgroundTransparency = 1
  247. resolverLabel.Parent = settingsFrame
  248.  
  249. local resolverToggle = Instance.new("TextButton")
  250. resolverToggle.Size = UDim2.new(0, 100, 0, 30)
  251. resolverToggle.Position = UDim2.new(0, 140, 0, 90)
  252. resolverToggle.Text = "ON"
  253. resolverToggle.Font = Enum.Font.Gotham
  254. resolverToggle.BackgroundColor3 = Color3.fromRGB(50, 200, 50)
  255. resolverToggle.TextColor3 = Color3.new(1, 1, 1)
  256. resolverToggle.Parent = settingsFrame
  257.  
  258. resolverToggle.MouseButton1Click:Connect(function()
  259. resolverActive = not resolverActive
  260. resolverToggle.Text = resolverActive and "ON" or "OFF"
  261. resolverToggle.BackgroundColor3 = resolverActive and Color3.fromRGB(50, 200, 50) or Color3.fromRGB(200, 50, 50)
  262. end)
  263.  
  264. lockButton.MouseButton1Click:Connect(function()
  265. if isLockedOn then
  266. stopLockingOn()
  267. lockButton.Text = "Lock On"
  268. else
  269. lockOn()
  270. lockButton.Text = "Lock On (Active)"
  271. end
  272. end)
  273.  
  274. settingsButton.MouseButton1Click:Connect(function()
  275. settingsFrame.Visible = not settingsFrame.Visible
  276. end)
  277.  
  278. smoothnessBox.FocusLost:Connect(function()
  279. local newSmoothness = tonumber(smoothnessBox.Text)
  280. if newSmoothness then
  281. smoothSpeed = math.clamp(newSmoothness, 0.01, 10)
  282. end
  283. end)
  284.  
  285. predictionBox.FocusLost:Connect(function()
  286. local newPrediction = tonumber(predictionBox.Text)
  287. if newPrediction then
  288. predictionValue = newPrediction
  289. end
  290. end)
  291. end
  292.  
  293. createGUI()
  294.  
  295. game:GetService("RunService").Heartbeat:Connect(function()
  296. if isLockedOn and lockedPlayer then
  297.  
  298. smoothlyDragToPlayer(lockedPlayer)
  299.  
  300.  
  301. if lookAtEnabled then
  302. local targetPosition = lockedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
  303.  
  304. local direction = (targetPosition - player.Character.HumanoidRootPart.Position).unit
  305. local lookAtCFrame = CFrame.lookAt(player.Character.HumanoidRootPart.Position, targetPosition)
  306.  
  307.  
  308. player.Character.HumanoidRootPart.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position, targetPosition)
  309.  
  310.  
  311. camera.CFrame = camera.CFrame:Lerp(CFrame.new(camera.CFrame.Position, targetPosition), smoothSpeed)
  312. end
  313. end
  314. end)
  315.  
  316. player.CharacterAdded:Connect(function()
  317. createGUI()
  318. end)
Add Comment
Please, Sign In to add comment