Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Camera = workspace.CurrentCamera
- local UserInputService = game:GetService("UserInputService")
- local aimEnabled = false
- local lockedTarget = nil -- This will store the player we are locked onto
- local fovCircle = Drawing.new("Circle")
- fovCircle.Color = Color3.fromRGB(255, 255, 255)
- fovCircle.Transparency = 0.7
- fovCircle.NumSides = 100
- fovCircle.Radius = 100
- fovCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
- fovCircle.Visible = true
- local function isPlayerInFOV(player)
- local character = player.Character
- if character and character:FindFirstChild("Head") then -- Check if Head part exists
- local screenPosition, onScreen = Camera:WorldToScreenPoint(character.Head.Position)
- if onScreen then
- local distance = (Vector2.new(screenPosition.X, screenPosition.Y) - fovCircle.Position).magnitude
- return distance <= fovCircle.Radius
- end
- end
- return false
- end
- local function aimAtPlayer(player)
- local character = player.Character
- if character and character:FindFirstChild("Head") then -- Check if Head part exists
- local targetPosition = character.Head.Position -- Aim at the Head part
- local cameraCFrame = CFrame.new(Camera.CFrame.Position, targetPosition)
- Camera.CFrame = cameraCFrame
- end
- end
- UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if not gameProcessed and input.KeyCode == Enum.KeyCode.F then
- aimEnabled = not aimEnabled
- if not aimEnabled then
- lockedTarget = nil -- Unlock the target when toggled off
- end
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- if aimEnabled then
- if lockedTarget and lockedTarget.Character and lockedTarget.Character:FindFirstChild("Head") then
- -- Continue aiming at the locked target's head
- aimAtPlayer(lockedTarget)
- else
- -- If no target is locked, find a new one
- for _, player in ipairs(Players:GetPlayers()) do
- if player ~= LocalPlayer and isPlayerInFOV(player) then
- lockedTarget = player
- break
- end
- end
- end
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- fovCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)
- end)
Advertisement
Add Comment
Please, Sign In to add comment