AALTTz

aimlock

Oct 22nd, 2022
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. --FE Simple AimLock Script | Released Nov 2021 | Working.
  2. local Area = game:GetService("Workspace")
  3. local RunService = game:GetService("RunService")
  4. local UIS = game:GetService("UserInputService")
  5. local Players = game:GetService("Players")
  6. local LocalPlayer = Players.LocalPlayer
  7. local MyCharacter = LocalPlayer.Character
  8. local MyRoot = MyCharacter:FindFirstChild("HumanoidRootPart")
  9. local MyHumanoid = MyCharacter:FindFirstChild("Humanoid")
  10. local Mouse = LocalPlayer:GetMouse()
  11. local MyView = Area.CurrentCamera
  12. local MyTeamColor = LocalPlayer.TeamColor
  13. local HoldingM2 = false
  14. local Active = false
  15. local Lock = false
  16. local Epitaph = .187 ---Note: The Bigger The Number, The More Prediction.
  17. local HeadOffset = Vector3.new(0, .1, 0)
  18.  
  19. _G.TeamCheck = false
  20. _G.AimPart = "HumanoidRootPart"
  21. _G.Sensitivity = 0
  22. _G.CircleSides = 64
  23. _G.CircleColor = Color3.fromRGB(255, 0, 130)
  24. _G.CircleTransparency = 0
  25. _G.CircleRadius = 200
  26. _G.CircleFilled = false
  27. _G.CircleVisible = true
  28. _G.CircleThickness = 1
  29.  
  30. local FOVCircle = Drawing.new("Circle")
  31. FOVCircle.Position = Vector2.new(MyView.ViewportSize.X / 2, MyView.ViewportSize.Y / 2)
  32. FOVCircle.Radius = _G.CircleRadius
  33. FOVCircle.Filled = _G.CircleFilled
  34. FOVCircle.Color = _G.CircleColor
  35. FOVCircle.Visible = _G.CircleVisible
  36. FOVCircle.Transparency = _G.CircleTransparency
  37. FOVCircle.NumSides = _G.CircleSides
  38. FOVCircle.Thickness = _G.CircleThickness
  39.  
  40. local function CursorLock()
  41. UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
  42. end
  43. local function UnLockCursor()
  44. HoldingM2 = false Active = false Lock = false
  45. UIS.MouseBehavior = Enum.MouseBehavior.Default
  46. end
  47. function FindNearestPlayer()
  48. local dist = math.huge
  49. local Target = nil
  50. for _, v in pairs(Players:GetPlayers()) do
  51. if v ~= LocalPlayer and v.Character:FindFirstChild("Humanoid") and v.Character:FindFirstChild("Humanoid").Health > 0 and v.Character:FindFirstChild("HumanoidRootPart") and v then
  52. local TheirCharacter = v.Character
  53. local CharacterRoot, Visible = MyView:WorldToViewportPoint(TheirCharacter[_G.AimPart].Position)
  54. if Visible then
  55. local RealMag = (Vector2.new(Mouse.X, Mouse.Y) - Vector2.new(CharacterRoot.X, CharacterRoot.Y)).Magnitude
  56. if RealMag < dist and RealMag < FOVCircle.Radius then
  57. dist = RealMag
  58. Target = TheirCharacter
  59. end
  60. end
  61. end
  62. end
  63. return Target
  64. end
  65.  
  66. UIS.InputBegan:Connect(function(Input)
  67. if Input.UserInputType == Enum.UserInputType.MouseButton2 then
  68. HoldingM2 = true
  69. Active = true
  70. Lock = true
  71. if Active then
  72. local The_Enemy = FindNearestPlayer()
  73. while HoldingM2 do task.wait(.000001)
  74. if Lock and The_Enemy ~= nil then
  75. local Future = The_Enemy.HumanoidRootPart.CFrame + (The_Enemy.HumanoidRootPart.Velocity * Epitaph + HeadOffset)
  76. MyView.CFrame = CFrame.lookAt(MyView.CFrame.Position, Future.Position)
  77. CursorLock()
  78. end
  79. end
  80. end
  81. end
  82. end)
  83. UIS.InputEnded:Connect(function(Input)
  84. if Input.UserInputType == Enum.UserInputType.MouseButton2 then
  85. UnLockCursor()
  86. end
  87. end)
  88. game.StarterGui:SetCore("SendNotification", {Title = "Working.", Text = "Success, Script Loaded.", Duration = 4,})
Add Comment
Please, Sign In to add comment