BubiStu

Untitled

Feb 16th, 2025 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local LocalPlayer = Players.LocalPlayer
  3. local Camera = workspace.CurrentCamera
  4. local UserInputService = game:GetService("UserInputService")
  5.  
  6. local aimEnabled = false
  7. local lockedTarget = nil -- This will store the player we are locked onto
  8. local fovCircle = Drawing.new("Circle")
  9. fovCircle.Color = Color3.fromRGB(255, 255, 255)
  10. fovCircle.Transparency = 0.7
  11. fovCircle.NumSides = 100
  12. fovCircle.Radius = 100
  13. fovCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
  14. fovCircle.Visible = true
  15.  
  16. local function isPlayerInFOV(player)
  17. local character = player.Character
  18. if character and character:FindFirstChild("Head") then -- Check if Head part exists
  19. local screenPosition, onScreen = Camera:WorldToScreenPoint(character.Head.Position)
  20. if onScreen then
  21. local distance = (Vector2.new(screenPosition.X, screenPosition.Y) - fovCircle.Position).magnitude
  22. return distance <= fovCircle.Radius
  23. end
  24. end
  25. return false
  26. end
  27.  
  28. local function aimAtPlayer(player)
  29. local character = player.Character
  30. if character and character:FindFirstChild("Head") then -- Check if Head part exists
  31. local targetPosition = character.Head.Position -- Aim at the Head part
  32. local cameraCFrame = CFrame.new(Camera.CFrame.Position, targetPosition)
  33. Camera.CFrame = cameraCFrame
  34. end
  35. end
  36.  
  37. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  38. if not gameProcessed and input.KeyCode == Enum.KeyCode.F then
  39. aimEnabled = not aimEnabled
  40. if not aimEnabled then
  41. lockedTarget = nil -- Unlock the target when toggled off
  42. end
  43. end
  44. end)
  45.  
  46. game:GetService("RunService").RenderStepped:Connect(function()
  47. if aimEnabled then
  48. if lockedTarget and lockedTarget.Character and lockedTarget.Character:FindFirstChild("Head") then
  49. -- Continue aiming at the locked target's head
  50. aimAtPlayer(lockedTarget)
  51. else
  52. -- If no target is locked, find a new one
  53. for _, player in ipairs(Players:GetPlayers()) do
  54. if player ~= LocalPlayer and isPlayerInFOV(player) then
  55. lockedTarget = player
  56. break
  57. end
  58. end
  59. end
  60. end
  61. end)
  62.  
  63. game:GetService("RunService").RenderStepped:Connect(function()
  64. fovCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
  65. end)
Advertisement
Add Comment
Please, Sign In to add comment