-- Lock On Script (TSB style, with animation trigger) --[[ WARNING: Heads up! This script has not been verified by ScriptBlox. Use at your own risk! ]] local Players = game:GetService("Players") local RunService = game:GetService("RunService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera local playerGui = player:WaitForChild("PlayerGui") -- CONFIG local LOCK_ON_ANIM_ID = "10470389827" -- Animation ID to trigger lock-on local MAX_DISTANCE = 50 -- GUI local screenGui = Instance.new("ScreenGui", playerGui) screenGui.Name = "LockOnGui" local button = Instance.new("TextButton", screenGui) button.Name = "LockOnButton" button.Size = UDim2.new(0, 35, 0, 35) button.Position = UDim2.new(0, 605, 0, -40) button.Text = "Lock" button.TextScaled = true button.BackgroundColor3 = Color3.fromRGB(50, 50, 50) button.TextColor3 = Color3.fromRGB(255, 255, 255) button.BackgroundTransparency = 0.4 local glowFrame = Instance.new("Frame", button) glowFrame.Size = UDim2.new(1.2, 0, 1.2, 0) glowFrame.Position = UDim2.new(0, -5, 0, -5) glowFrame.BackgroundTransparency = 1 glowFrame.BackgroundColor3 = Color3.fromRGB(0, 255, 0) local glowGradient = Instance.new("UIGradient", glowFrame) glowGradient.Color = ColorSequence.new(Color3.fromRGB(0, 255, 0), Color3.fromRGB(0, 255, 0)) glowGradient.Transparency = NumberSequence.new(0.5, 1) glowGradient.Rotation = 45 glowFrame.Visible = false -- Vars local isLockedOn = false local target = nil -- Nearest Target Finder local function getNearestTarget() local nearest = nil local shortest = MAX_DISTANCE local char = player.Character if not (char and char:FindFirstChild("HumanoidRootPart")) then return nil end local playerPos = char.HumanoidRootPart.Position for _, obj in ipairs(workspace:GetDescendants()) do if obj:IsA("Model") and obj ~= char and obj:FindFirstChild("Humanoid") and obj:FindFirstChild("HumanoidRootPart") then local dist = (obj.HumanoidRootPart.Position - playerPos).Magnitude if dist < shortest then shortest = dist nearest = obj end end end return nearest end -- LockOn Functions local function startLockOn() if isLockedOn then return end isLockedOn = true button.BackgroundColor3 = Color3.fromRGB(102, 255, 102) glowFrame.Visible = true if not target then target = getNearestTarget() end end local function stopLockOn() isLockedOn = false target = nil button.BackgroundColor3 = Color3.fromRGB(50, 50, 50) glowFrame.Visible = false if player.Character and player.Character:FindFirstChild("Humanoid") then camera.CameraSubject = player.Character.Humanoid end end -- Update Camera RunService.RenderStepped:Connect(function() if isLockedOn and target then local hrp = target:FindFirstChild("HumanoidRootPart") if hrp and target:FindFirstChild("Humanoid").Health > 0 then local camPos = camera.CFrame.Position local dir = (hrp.Position - camPos).Unit camera.CFrame = CFrame.new(camPos, camPos + dir) else stopLockOn() end end end) -- Detect Animation Play local function setupAnimDetection(char) local humanoid = char:WaitForChild("Humanoid") local animator = humanoid:WaitForChild("Animator") animator.AnimationPlayed:Connect(function(track) local id = string.match(track.Animation.AnimationId, "%d+") if id == LOCK_ON_ANIM_ID then startLockOn() -- Stop lock-on when animation stops track.Stopped:Connect(function() stopLockOn() end) end end) end -- Hook when character spawns player.CharacterAdded:Connect(setupAnimDetection) if player.Character then setupAnimDetection(player.Character) end