Run it
Copy the script and paste it into your executor.
-- Created by MrOrmsman
-- Get the player's character
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- Create a function to aim at a target
local function aimAt(target)
-- Calculate the direction to the target
local direction = (target.Position - character.Head.Position).Unit
-- Set the character's look vector to the direction
character:SetPrimaryPartCFrame(CFrame.new(character.PrimaryPart.Position, character.PrimaryPart.Position + direction))
end
-- Create a loop to continuously aim at the nearest enemy
while true do
-- Get all the players in the game
local players = game.Players:GetPlayers()
-- Find the nearest enemy
nearestEnemy =
nearestDistance = .huge
_, enemy (players)
enemy ~= player
enemyCharacter = enemy.Character
enemyCharacter
distance = (enemyCharacter.Head.Position - character.Head.Position).Magnitude
distance < nearestDistance
nearestEnemy = enemyCharacter
nearestDistance = distance
nearestEnemy
(nearestEnemy)
()