Advertisement
m9aari

Da strike script stuff

Nov 14th, 2024 (edited)
1,092
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. local aimlockRange = 100 -- Adjust the range to your preference
  2. local predictionFactor = 0.13 -- Adjust the prediction factor to your preference
  3.  
  4. -- Function to find the nearest player
  5. local function findNearestPlayer()
  6. local mouse = game.Players.LocalPlayer:GetMouse()
  7. local target = nil
  8. local minDist = aimlockRange
  9.  
  10. for _, player in ipairs(game.Players:GetPlayers()) do
  11. if player ~= game.Players.LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
  12. local char = player.Character
  13. local screenPos = game.Workspace.CurrentCamera:WorldToScreenPoint(char.HumanoidRootPart.Position)
  14. local dist = (Vector2.new(screenPos.X, screenPos.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  15. if dist < minDist then
  16. minDist = dist
  17. target = char.HumanoidRootPart
  18. end
  19. end
  20. end
  21.  
  22. return target
  23. end
  24.  
  25. -- Enable aimlock immediately when the script runs
  26. local aimlockEnabled = true
  27. local lockedPlayer = findNearestPlayer() -- Find the nearest player when aimlock is enabled
  28.  
  29. -- Function to handle aimlock rendering with prediction
  30. game:GetService("RunService").RenderStepped:Connect(function()
  31. if aimlockEnabled and lockedPlayer then
  32. local targetPos = lockedPlayer.Position
  33. local targetVelocity = lockedPlayer.Velocity
  34. local predictedPos = targetPos + targetVelocity * predictionFactor
  35. local camera = game.Workspace.CurrentCamera
  36. camera.CFrame = CFrame.new(camera.CFrame.Position, predictedPos)
  37. end
  38. end)
  39.  
  40. -- Handle aimlock behavior with 'F' key
  41. game:GetService("UserInputService").InputBegan:Connect(function(input)
  42. if input.KeyCode == Enum.KeyCode.F then
  43. if aimlockEnabled and lockedPlayer then
  44. lockedPlayer = nil
  45. elseif aimlockEnabled then
  46. lockedPlayer = findNearestPlayer()
  47. end
  48. end
  49. end)
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement