local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local Players = game:GetService("Players") local player = Players.LocalPlayer local enemiesFolder = workspace:WaitForChild("Enemies") local TARGET_KEY = Enum.KeyCode.P local OFFSET = Vector3.new(0, 0, 0) local scanActive = false local currentTarget = nil local function findNextEnemy() local closestModel = nil local shortestDistance = math.huge local character = player.Character if not character or not character:FindFirstChild("HumanoidRootPart") then return nil end local myPos = character.HumanoidRootPart.Position for _, enemy in ipairs(enemiesFolder:GetChildren()) do local root = enemy:FindFirstChild("HumanoidRootPart") local hum = enemy:FindFirstChild("Humanoid") if root and hum and hum.Health > 0 then local dist = (root.Position - myPos).Magnitude if dist < shortestDistance then closestModel = enemy shortestDistance = dist end end end return closestModel end UserInputService.InputBegan:Connect(function(input, processed) if processed then return end if input.KeyCode == TARGET_KEY then scanActive = not scanActive if not scanActive then currentTarget = nil print("Sticky Mode: OFF") else print("Sticky Mode: ON (Inside NPC)") end end end) RunService.Heartbeat:Connect(function() if not scanActive then return end local character = player.Character if not character or not character:FindFirstChild("HumanoidRootPart") then return end local myRoot = character.HumanoidRootPart local isValid = false if currentTarget and currentTarget:IsDescendantOf(enemiesFolder) then local hum = currentTarget:FindFirstChild("Humanoid") if hum and hum.Health > 0 then isValid = true end end if not isValid then currentTarget = findNextEnemy() end if currentTarget then local targetRoot = currentTarget:FindFirstChild("HumanoidRootPart") if targetRoot then myRoot.CFrame = targetRoot.CFrame end end end)