Thank you for using our website
Your script:
-- Variables
local AIM_ENABLED = false
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local UserInputService = game:GetService("UserInputService")
-- Function to find the head of the target player
local function getHead(targetPlayer)
local character = targetPlayer.Character
if character then
return character:FindFirstChild("Head")
end
return nil
end
-- Function to check if a target is in the player's line of sight
local function isInLineOfSight(targetPart)
local origin = camera.CFrame.Position
local direction = (targetPart.Position - origin).unit * 1000
local ray = Ray.new(origin, direction)
local hit, position = workspace:FindPartOnRay(ray, player.Character)
return hit and hit:IsDescendantOf(targetPart.Parent)
end
-- Function to check if teams exist
local function teamsExist()
for _, targetPlayer in pairs(game.Players:GetPlayers()) do
if targetPlayer.Team then
return true
end
end
return false
end
-- Function to check if a player is an enemy (if teams exist)
local function isEnemy(targetPlayer)
if teamsExist() then
return targetPlayer.Team ~= player.Team
else
return true -- If no teams, consider everyone as a target
end
end
-- Function to check if a player is alive
local function isAlive(targetPlayer)
local character = targetPlayer.Character
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid and humanoid.Health > 0 then
return true
end
end
return false
end
-- Function to check if a player has a forcefield
local function hasForceField(targetPlayer)
local character = targetPlayer.Character
if character then
return character:FindFirstChild("ForceField") ~= nil
end
return false
end
-- Function to aim at the head of the target player
local function aimAtHead()
for _, targetPlayer in pairs(game.Players:GetPlayers()) do
if targetPlayer ~= player and isEnemy(targetPlayer) and isAlive(targetPlayer) and not hasForceField(targetPlayer) then
local head = getHead(targetPlayer)
if head and isInLineOfSight(head) then
-- Aim the camera at the head
camera.CFrame = CFrame.new(camera.CFrame.Position, head.Position)
break
end
end
end
end
-- Function to toggle aim assist
local function toggleAim()
AIM_ENABLED = not AIM_ENABLED
if AIM_ENABLED then
print("Aim assist enabled")
else
print("Aim assist disabled")
end
end
-- Bind the toggle function to the "P" key
UserInputService.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.P and not processed then
toggleAim()
end
end)
-- Continuously check for aim assist when enabled
game:GetService("RunService").RenderStepped:Connect(function()
if AIM_ENABLED then
aimAtHead()
end
end)