Okb00mer

Untitled

Feb 27th, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.91 KB | None | 0 0
  1. getgenv().OldAimPart = "UpperTorso"
  2. getgenv().AimPart = "UpperTorso"
  3. getgenv().AimlockKey = "q"
  4. getgenv().AimRadius = 7.22
  5. getgenv().ThirdPerson = true
  6. getgenv().FirstPerson = true
  7. getgenv().TeamCheck = false
  8. getgenv().PredictMovement = true
  9. getgenv().PredictionVelocity = 25
  10. getgenv().CheckIfJumped = true
  11. getgenv().Smoothness = true
  12. getgenv().SmoothnessAmount = 0.0421
  13.  
  14. local Players, Uis, RService, SGui = game:GetService"Players", game:GetService"UserInputService", game:GetService"RunService", game:GetService"StarterGui";
  15. local Client, Mouse, Camera, CF, RNew, Vec3, Vec2 = Players.LocalPlayer, Players.LocalPlayer:GetMouse(), workspace.CurrentCamera, CFrame.new, Ray.new, Vector3.new, Vector2.new;
  16. local Aimlock, MousePressed, CanNotify = true, false, false;
  17. local AimlockTarget;
  18. local OldPre;
  19.  
  20.  
  21.  
  22. getgenv().WorldToViewportPoint = function(P)
  23. return Camera:WorldToViewportPoint(P)
  24. end
  25.  
  26. getgenv().WorldToScreenPoint = function(P)
  27. return Camera.WorldToScreenPoint(Camera, P)
  28. end
  29.  
  30. getgenv().GetObscuringObjects = function(T)
  31. if T and T:FindFirstChild(getgenv().AimPart) and Client and Client.Character:FindFirstChild("Head") then
  32. local RayPos = workspace:FindPartOnRay(RNew(
  33. T[getgenv().AimPart].Position, Client.Character.Head.Position)
  34. )
  35. if RayPos then return RayPos:IsDescendantOf(T) end
  36. end
  37. end
  38.  
  39. getgenv().GetNearestTarget = function()
  40. local players = {}
  41. local PLAYER_HOLD = {}
  42. local DISTANCES = {}
  43. for i, v in pairs(Players:GetPlayers()) do
  44. if v ~= Client then
  45. table.insert(players, v)
  46. end
  47. end
  48. for i, v in pairs(players) do
  49. if v.Character ~= nil then
  50. local AIM = v.Character:FindFirstChild("Head")
  51. if getgenv().TeamCheck == true and v.Team ~= Client.Team then
  52. local DISTANCE = (v.Character:FindFirstChild("Head").Position - game.Workspace.CurrentCamera.CFrame.p).magnitude
  53. local RAY = Ray.new(game.Workspace.CurrentCamera.CFrame.p, (Mouse.Hit.p - game.Workspace.CurrentCamera.CFrame.p).unit * DISTANCE)
  54. local HIT,POS = game.Workspace:FindPartOnRay(RAY, game.Workspace)
  55. local DIFF = math.floor((POS - AIM.Position).magnitude)
  56. PLAYER_HOLD[v.Name .. i] = {}
  57. PLAYER_HOLD[v.Name .. i].dist= DISTANCE
  58. PLAYER_HOLD[v.Name .. i].plr = v
  59. PLAYER_HOLD[v.Name .. i].diff = DIFF
  60. table.insert(DISTANCES, DIFF)
  61. elseif getgenv().TeamCheck == false and v.Team == Client.Team then
  62. local DISTANCE = (v.Character:FindFirstChild("Head").Position - game.Workspace.CurrentCamera.CFrame.p).magnitude
  63. local RAY = Ray.new(game.Workspace.CurrentCamera.CFrame.p, (Mouse.Hit.p - game.Workspace.CurrentCamera.CFrame.p).unit * DISTANCE)
  64. local HIT,POS = game.Workspace:FindPartOnRay(RAY, game.Workspace)
  65. local DIFF = math.floor((POS - AIM.Position).magnitude)
  66. PLAYER_HOLD[v.Name .. i] = {}
  67. PLAYER_HOLD[v.Name .. i].dist= DISTANCE
  68. PLAYER_HOLD[v.Name .. i].plr = v
  69. PLAYER_HOLD[v.Name .. i].diff = DIFF
  70. table.insert(DISTANCES, DIFF)
  71. end
  72. end
  73. end
  74.  
  75. if unpack(DISTANCES) == nil then
  76. return nil
  77. end
  78.  
  79. local L_DISTANCE = math.floor(math.min(unpack(DISTANCES)))
  80. if L_DISTANCE > getgenv().AimRadius then
  81. return nil
  82. end
  83.  
  84. for i, v in pairs(PLAYER_HOLD) do
  85. if v.diff == L_DISTANCE then
  86. return v.plr
  87. end
  88. end
  89. return nil
  90. end
  91.  
  92. Mouse.KeyDown:Connect(function(a)
  93. if not (Uis:GetFocusedTextBox()) then
  94. if a == AimlockKey and AimlockTarget == nil then
  95. pcall(function()
  96. if MousePressed ~= true then MousePressed = true end
  97. local Target;Target = GetNearestTarget()
  98. if Target ~= nil then
  99. AimlockTarget = Target
  100. end
  101. end)
  102. elseif a == AimlockKey and AimlockTarget ~= nil then
  103. if AimlockTarget ~= nil then AimlockTarget = nil end
  104. if MousePressed ~= false then
  105. MousePressed = false
  106. end
  107. end
  108. end
  109. end)
  110.  
  111. RService.RenderStepped:Connect(function()
  112. if getgenv().ThirdPerson == true and getgenv().FirstPerson == true then
  113. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 1 or (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1 then
  114. CanNotify = true
  115. else
  116. CanNotify = false
  117. end
  118. elseif getgenv().ThirdPerson == true and getgenv().FirstPerson == false then
  119. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude > 1 then
  120. CanNotify = true
  121. else
  122. CanNotify = false
  123. end
  124. elseif getgenv().ThirdPerson == false and getgenv().FirstPerson == true then
  125. if (Camera.Focus.p - Camera.CoordinateFrame.p).Magnitude <= 1 then
  126. CanNotify = true
  127. else
  128. CanNotify = false
  129. end
  130. end
  131. if Aimlock == true and MousePressed == true then
  132. if AimlockTarget and AimlockTarget.Character and AimlockTarget.Character:FindFirstChild(getgenv().AimPart) then
  133. if getgenv().FirstPerson == true then
  134. if CanNotify == true then
  135. if getgenv().PredictMovement == true then
  136. if getgenv().Smoothness == true then
  137. --// The part we're going to lerp/smoothen \\--
  138. local Main = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position + AimlockTarget.Character[getgenv().AimPart].Velocity/PredictionVelocity)
  139.  
  140. --// Making it work \\--
  141. Camera.CFrame = Camera.CFrame:Lerp(Main, getgenv().SmoothnessAmount, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut)
  142. else
  143. Camera.CFrame = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position + AimlockTarget.Character[getgenv().AimPart].Velocity/PredictionVelocity)
  144. end
  145. elseif getgenv().PredictMovement == false then
  146. if getgenv().Smoothness == true then
  147. --// The part we're going to lerp/smoothen \\--
  148. local Main = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position)
  149.  
  150. --// Making it work \\--
  151. Camera.CFrame = Camera.CFrame:Lerp(Main, getgenv().SmoothnessAmount, Enum.EasingStyle.Elastic, Enum.EasingDirection.InOut)
  152. else
  153. Camera.CFrame = CF(Camera.CFrame.p, AimlockTarget.Character[getgenv().AimPart].Position)
  154. end
  155. end
  156. end
  157. end
  158. end
  159. end
  160. if CheckIfJumped == true then
  161. if AimlockTarget.Character.HuDDDDDDDDDDWmanoid.FloorMaterial == Enum.Material.Air then
  162.  
  163. getgenv().AimPart = "UpperTorso"
  164. else
  165. getgenv().AimPart = getgenv().OldAimPart
  166.  
  167. end
  168. end
  169. end)
Add Comment
Please, Sign In to add comment