Advertisement
Hfghbfhvvbjvghhg

Aimbot fov (mobile support)

Jul 28th, 2024
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | Gaming | 0 0
  1. -- Credit TomoEdits --
  2.  
  3. local fov = 60
  4. local maxDistance = 400
  5. local maxTransparency = 0.1
  6. local teamCheck = false
  7. local wallCheck = false
  8. local aimPart = "Head" -- "Torso"
  9.  
  10. local RunService = game:GetService("RunService")
  11. local Players = game:GetService("Players")
  12. local Cam = game.Workspace.CurrentCamera
  13.  
  14. local FOVring = Drawing.new("Circle")
  15. FOVring.Visible = true
  16. FOVring.Thickness = 2
  17. FOVring.Color = Color3.fromRGB(0, 0, 0)
  18. FOVring.Filled = false
  19. FOVring.Radius = fov
  20. FOVring.Position = Cam.ViewportSize / 2
  21.  
  22. local function updateDrawings()
  23. FOVring.Position = Cam.ViewportSize / 2
  24. end
  25.  
  26. local function lookAt(target)
  27. local lookVector = (target - Cam.CFrame.Position).unit
  28. local newCFrame = CFrame.new(Cam.CFrame.Position, Cam.CFrame.Position + lookVector)
  29. Cam.CFrame = newCFrame
  30. end
  31.  
  32. local function calculateTransparency(distance)
  33. return (1 - (distance / fov)) * maxTransparency
  34. end
  35.  
  36. local function isPlayerAlive(player)
  37. local character = player.Character
  38. return character and character:FindFirstChild("Humanoid") and character.Humanoid.Health > 0
  39. end
  40.  
  41. local function isPlayerVisibleThroughWalls(player, trg_part)
  42. if not wallCheck then
  43. return true
  44. end
  45.  
  46. local localPlayerCharacter = Players.LocalPlayer.Character
  47. if not localPlayerCharacter then
  48. return false
  49. end
  50.  
  51. local part = player.Character and player.Character:FindFirstChild(trg_part)
  52. if not part then
  53. return false
  54. end
  55.  
  56. local ray = Ray.new(Cam.CFrame.Position, part.Position - Cam.CFrame.Position)
  57. local hit, _ = workspace:FindPartOnRayWithIgnoreList(ray, {localPlayerCharacter})
  58.  
  59. if hit and hit:IsDescendantOf(player.Character) then
  60. return true
  61. end
  62.  
  63. -- Fallback to a nearby position if the direct ray doesn't hit
  64. local direction = (part.Position - Cam.CFrame.Position).unit
  65. local nearRay = Ray.new(Cam.CFrame.Position + direction * 2, direction * maxDistance)
  66. local nearHit, _ = workspace:FindPartOnRayWithIgnoreList(nearRay, {localPlayerCharacter})
  67.  
  68. return nearHit and nearHit:IsDescendantOf(player.Character)
  69. end
  70.  
  71. local function getClosestPlayerInFOV()
  72. local nearest = nil
  73. local last = math.huge
  74. local playerMousePos = Cam.ViewportSize / 2
  75. local localPlayer = Players.LocalPlayer
  76.  
  77. for _, player in ipairs(Players:GetPlayers()) do
  78. if player ~= localPlayer and (not teamCheck or player.Team ~= localPlayer.Team) and isPlayerAlive(player) then
  79. local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
  80. local part = player.Character and player.Character:FindFirstChild(aimPart)
  81. if humanoid and part then
  82. local ePos, isVisible = Cam:WorldToViewportPoint(part.Position)
  83. local distance = (Vector2.new(ePos.x, ePos.y) - playerMousePos).Magnitude
  84.  
  85. if distance < last and isVisible and distance < fov and distance < maxDistance and isPlayerVisibleThroughWalls(player, aimPart) then
  86. last = distance
  87. nearest = player
  88. end
  89. end
  90. end
  91. end
  92.  
  93. return nearest
  94. end
  95.  
  96. RunService.RenderStepped:Connect(function()
  97. updateDrawings()
  98. local closest = getClosestPlayerInFOV()
  99. if closest and closest.Character:FindFirstChild(aimPart) then
  100. lookAt(closest.Character[aimPart].Position)
  101. end
  102.  
  103. if closest then
  104. local part = closest.Character[aimPart]
  105. local ePos, isVisible = Cam:WorldToViewportPoint(part.Position)
  106. local distance = (Vector2.new(ePos.x, ePos.y) - (Cam.ViewportSize / 2)).Magnitude
  107. FOVring.Transparency = calculateTransparency(distance)
  108. else
  109. FOVring.Transparency = maxTransparency
  110. end
  111. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement