benxogian

Untitled

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