local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Teams = game:GetService("Teams") local VirtualInputManager = game:GetService("VirtualInputManager") local LocalPlayer = Players.LocalPlayer local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") local targetPlayer = nil local isEnabled = false local teleportDistance = 3 -- Distance behind the target local targetSelectionMode = "closest" -- "closest" or "random" local lastAttackTime = 0 local attackCooldown = 0.2 -- Cooldown between attacks local weaponEquipped = false local maxTargetVelocity = 100 -- Maximum allowed target velocity magnitude local lastTargetPosition = Vector3.new(0, 0, 0) local lastPositionCheckTime = 0 local function isDifferentTeam(player) if not LocalPlayer.Team then return true end if player.Team and player.Team.TeamColor ~= LocalPlayer.Team.TeamColor then return true end return false end local function getValidTargets() local validTargets = {} for _, player in pairs(Players:GetPlayers()) do if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") and player.Character:FindFirstChild("Humanoid") and player.Character.Humanoid.Health > 0 and isDifferentTeam(player) then table.insert(validTargets, player) end end return validTargets end local function findClosestPlayer() local validTargets = getValidTargets() local closestPlayer = nil local shortestDistance = math.huge for _, player in ipairs(validTargets) do local distance = (player.Character.HumanoidRootPart.Position - HumanoidRootPart.Position).Magnitude if distance < shortestDistance then shortestDistance = distance closestPlayer = player end end return closestPlayer end local function findRandomPlayer() local validTargets = getValidTargets() if #validTargets > 0 then return validTargets[math.random(1, #validTargets)] end return nil end local function selectTarget() if targetSelectionMode == "closest" then return findClosestPlayer() else return findRandomPlayer() end end local function isWeaponEquipped() return Character:FindFirstChildOfClass("Tool") ~= nil end local function equipFirstWeaponSlot() if isWeaponEquipped() then weaponEquipped = true return end VirtualInputManager:SendKeyEvent(true, Enum.KeyCode.One, false, game) task.wait(0.05) VirtualInputManager:SendKeyEvent(false, Enum.KeyCode.One, false, game) weaponEquipped = true end local function performAttack() local currentTime = tick() if currentTime - lastAttackTime < attackCooldown then return end lastAttackTime = currentTime VirtualInputManager:SendMouseButtonEvent(0, 0, 0, true, game, 1) task.wait(0.05) VirtualInputManager:SendMouseButtonEvent(0, 0, 0, false, game, 1) end local function isTargetMovingTooFast() if not targetPlayer or not targetPlayer.Character or not targetPlayer.Character:FindFirstChild("HumanoidRootPart") then return false end local currentTime = tick() local targetHRP = targetPlayer.Character.HumanoidRootPart local currentPosition = targetHRP.Position if targetHRP.Velocity.Magnitude > maxTargetVelocity then return true end if currentTime - lastPositionCheckTime > 0.1 then local distance = (currentPosition - lastTargetPosition).Magnitude local timeElapsed = currentTime - lastPositionCheckTime local speed = distance / timeElapsed lastTargetPosition = currentPosition lastPositionCheckTime = currentTime if speed > maxTargetVelocity then return true end end return false end local function teleportBehindTarget() if not targetPlayer or not targetPlayer.Character or not targetPlayer.Character:FindFirstChild("HumanoidRootPart") or not targetPlayer.Character:FindFirstChild("Humanoid") or targetPlayer.Character.Humanoid.Health <= 0 then targetPlayer = selectTarget() if not targetPlayer then return end lastTargetPosition = targetPlayer.Character.HumanoidRootPart.Position lastPositionCheckTime = tick() end if isTargetMovingTooFast() then targetPlayer = selectTarget() if not targetPlayer then return end lastTargetPosition = targetPlayer.Character.HumanoidRootPart.Position lastPositionCheckTime = tick() end local targetHRP = targetPlayer.Character.HumanoidRootPart local targetCFrame = targetHRP.CFrame local behindPosition = targetCFrame.Position - (targetCFrame.LookVector * teleportDistance) local newCFrame = CFrame.new(behindPosition, targetCFrame.Position) if Character and HumanoidRootPart then HumanoidRootPart.CFrame = newCFrame if autoAttackEnabled then if not weaponEquipped then equipFirstWeaponSlot() end performAttack() end end end local function checkTargetStatus() if targetPlayer and targetPlayer.Character and targetPlayer.Character:FindFirstChild("Humanoid") then if targetPlayer.Character.Humanoid.Health <= 0 or not isDifferentTeam(targetPlayer) then targetPlayer = selectTarget() if targetPlayer then lastTargetPosition = targetPlayer.Character.HumanoidRootPart.Position lastPositionCheckTime = tick() end end else targetPlayer = selectTarget() if targetPlayer then lastTargetPosition = targetPlayer.Character.HumanoidRootPart.Position lastPositionCheckTime = tick() end end end UserInputService.InputBegan:Connect(function(input, gameProcessed) if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftControl then isEnabled = not isEnabled if isEnabled then targetPlayer = selectTarget() if targetPlayer then lastTargetPosition = targetPlayer.Character.HumanoidRootPart.Position lastPositionCheckTime = tick() end if not weaponEquipped and autoAttackEnabled then equipFirstWeaponSlot() end else targetPlayer = nil end end if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftAlt then if targetSelectionMode == "closest" then targetSelectionMode = "random" else targetSelectionMode = "closest" end if isEnabled then targetPlayer = selectTarget() if targetPlayer then lastTargetPosition = targetPlayer.Character.HumanoidRootPart.Position lastPositionCheckTime = tick() end end end if not gameProcessed and input.KeyCode == Enum.KeyCode.LeftShift then autoAttackEnabled = not autoAttackEnabled if autoAttackEnabled and isEnabled and not weaponEquipped then equipFirstWeaponSlot() end end end) RunService.Heartbeat:Connect(function() if isEnabled then checkTargetStatus() teleportBehindTarget() end end) LocalPlayer.CharacterAdded:Connect(function(newCharacter) Character = newCharacter Humanoid = Character:WaitForChild("Humanoid") HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") weaponEquipped = false end) Character.ChildRemoved:Connect(function(child) if child:IsA("Tool") then weaponEquipped = false end end)