local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
-- Configuration
local ROTATION_SPEED = 0.1 -- Smooth rotation speed
local TRACKED_PLAYER = nil -- Player you are currently targeting
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- Function to handle clicking on a player to target them
local function onPlayerClicked(targetPlayer)
if targetPlayer and targetPlayer.Character then
TRACKED_PLAYER = targetPlayer
end
end
-- Function to smoothly face the target player's direction
local function smoothFaceTarget(targetPlayer)
if targetPlayer and targetPlayer.Character then
local targetHumanoidRootPart = targetPlayer.Character:FindFirstChild("HumanoidRootPart")
if targetHumanoidRootPart then
local targetPosition = Vector3.new(targetHumanoidRootPart.Position.X, humanoidRootPart.Position.Y, targetHumanoidRootPart.Position.Z)
local targetCFrame = CFrame.lookAt(humanoidRootPart.Position, targetPosition)
-- Smoothly interpolate the humanoid's CFrame towards the target
humanoidRootPart.CFrame = humanoidRootPart.CFrame:Lerp(targetCFrame, ROTATION_SPEED)
end
end
end
-- Function to update the ESP to show which player is being tracked
local function updateESP()
if TRACKED_PLAYER and TRACKED_PLAYER.Character then
-- Simple ESP logic, you can add visual effects here (for example, a part above the player's head)
local targetHead = TRACKED_PLAYER.Character:FindFirstChild("Head")
if targetHead then
-- Create a simple BillboardGui to show ESP
local billboard = Instance.new("BillboardGui")
billboard.Adornee = targetHead
billboard.Size = UDim2.new(0, 100, 0, 100)
billboard.StudsOffset = Vector3.new(0, 2, 0)
billboard.AlwaysOnTop = true
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "Targeted"
textLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
textLabel.BackgroundTransparency = 1
textLabel.TextStrokeTransparency = 0.8
textLabel.Parent = billboard
billboard.Parent = game.Players.LocalPlayer.PlayerGui
end
end
end
-- Listen for player clicks to target
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local mouse = player:GetMouse()
local target = mouse.Target
if target and target.Parent and target.Parent:FindFirstChild("Humanoid") then
onPlayerClicked(Players:GetPlayerFromCharacter(target.Parent))
end
end
end)
-- Ensure the script continues working when the character respawns
player.CharacterAdded:Connect(function(newCharacter)
character = newCharacter
humanoidRootPart = newCharacter:WaitForChild("HumanoidRootPart")
-- Reconnect ESP for the new character if necessary
end)
-- Run service to update the face tracking smoothly
RunService.RenderStepped:Connect(function()
if TRACKED_PLAYER then
smoothFaceTarget(TRACKED_PLAYER)
updateESP() -- Update the ESP every frame
end
end)